Skip to content

Commit

Permalink
Merge pull request #62 from vigoren/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
vigoren committed Apr 14, 2021
2 parents 2f89b5d + 3053f20 commit 39d6244
Show file tree
Hide file tree
Showing 58 changed files with 2,218 additions and 821 deletions.
39 changes: 39 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,44 @@
# Change Log

## v1.2.20 - Macros, Hooks, Bug Fixes and QoL Improvements

### Macros

- Added a new macro for setting a specific date/time for the calendar, check out the [documentation](./docs/Macros.md#set-date-and-time) for how to use it.
- Added a new macro for changing the current date/time by a passed in amount. Check out the [documentation](./docs/Macros.md#change-date-time) for how to use it.


### Hooks

Simple Calendar will now emit certain hooks that other modules/code can listen for.

- Added a hook that is fired every time the current date is changed and contains the information for the new date. Check out the [documentation](./docs/Hooks.md#datetime-change) for more details.

### Quality of Life Improvements

- Cleaned up the styling of the calendar dialog. The calendar will now consistently open so that the calendar, date controls (if gm) and 2 rows of notes will be visible.
- Resizing of the calendar dialog will now reset when you close and re-open the dialog.
- Added the Traveller - Imperial Calendar as a predefined calendar.
- Added a new section in month configuration called Advanced. Clicking on a months "Show Advanced" link will show the advanced options' area. This area will contain things that are probably not relevant to most calendars.
- Added a new option to months advanced settings to offset the day numbers by an amount. This is to accommodate instances where a month may start on day 2. The best example is the Traveller calendar where days are numbered by what day of the year they are rather than which day of the month they are.
- For calendars that have months with many days (example the traveller calendar) the calendar now has a maximum height of 500px. The list of days will become scrollable. For Current days or selected days the calendar will attempt to keep them in view when it makes sense (selecting a new day).
- Added the ability to specify the starting day of the week for the first day of year 0. This helps align your calendar with official calendars.
- Updated the pre-defined calendars to have their starting day of the week set so that they match with official calendars.
- There was no way to unselect a day so now if a selected day is clicked again it will become unselected.

### Bug Fixes

- Fixed a bug for games with multiple GMs. In some instances both GMs would get assigned as the primary GM and process changes, instead of only 1 processing the changes. This sometimes resulted in incorrect dates being set.
- Fixed an issue with the Exandrian pre defined calendar where I missed an entire weekday, big oops.


### Foundry 0.8.1

I have made a couple of small changes to Simple Calendar that allows it to work properly with Foundry version 0.8.1.

That version of Foundry is still in alpha, so I do warn against updating your main games to that Foundry version yet. This step in testing will hopefully allow a very seamless transition into 0.8.x when it is released for everyone.


## v1.2.5 - Bug Fixes and QoL Improvements

### Quality of Life Improvements
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Foundry Core Compatible Version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/vigoren/foundryvtt-simple-calendar/master/src/module.json&label=Foundry&query=$.compatibleCoreVersion&colorB=orange)](https://foundryvtt.com/releases/)
[![Foundry Core Minimum Version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/vigoren/foundryvtt-simple-calendar/master/src/module.json&label=Foundry%20Minimum%20Version&query=$.minimumCoreVersion&colorB=orange)](https://foundryvtt.com/releases/)
[![Foundry Core Compatible Version](https://img.shields.io/badge/dynamic/json.svg?url=https://raw.githubusercontent.com/vigoren/foundryvtt-simple-calendar/master/src/module.json&label=Foundry%20Compatible%20Version&query=$.compatibleCoreVersion&colorB=orange)](https://foundryvtt.com/releases/)
![GitHub package.json version](https://img.shields.io/github/package-json/v/vigoren/foundryvtt-simple-calendar)
[![license](https://img.shields.io/badge/license-MIT-blue)](https://github.com/vigoren/foundryvtt-simple-calendar/blob/main/LICENSE)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/vigoren/foundryvtt-simple-calendar/Node.js%20CI)
Expand All @@ -8,8 +9,11 @@
[![Foundry Hub Endorsements](https://img.shields.io/endpoint?logoColor=white&url=https://www.foundryvtt-hub.com/wp-json/hubapi/v1/package/foundryvtt-simple-calendar/shield/endorsements)](https://www.foundryvtt-hub.com/package/foundryvtt-simple-calendar/)
[![Foundry Hub Comments](https://img.shields.io/endpoint?logoColor=white&url=https://www.foundryvtt-hub.com/wp-json/hubapi/v1/package/foundryvtt-simple-calendar/shield/comments)](https://www.foundryvtt-hub.com/package/foundryvtt-simple-calendar/)

[![ko-fi](https://img.shields.io/badge/%20-Support%20me%20on%20Ko--fi-%23FF5E5B?style=flat&logo=ko-fi&logoColor=white)](https://ko-fi.com/A0A546HOX)

![Logo](https://raw.githubusercontent.com/vigoren/foundryvtt-simple-calendar/main/docs/images/logo.png)


# Simple Calendar

A simple calendar module for [FoundryVTT](https://foundryvtt.com/) that is system independent.
Expand All @@ -35,13 +39,17 @@ It is intended as a way for a GM to show a calendar like interface that maps to
* Add notes to specific days on the calendar to remind yourself of events or other world related things.
* These notes can either be visible to players as well as the GM or just the GM.

![GM View of Calendar](https://raw.githubusercontent.com/vigoren/foundryvtt-simple-calendar/main/docs/images/gm-screenshot-1.png)

### For Players

* Browse a calendar interface to see the years, months and day of the game world.
* See the current day and time of the game world.
* Select days to view any notes/events specific to that day.
* If the GM allows it, the ability to add their own notes to the calendar.

![Player View of Calendar](https://raw.githubusercontent.com/vigoren/foundryvtt-simple-calendar/main/docs/images/player.gif)

## Contents

- [Installation](#installing-the-module)
Expand All @@ -51,6 +59,7 @@ It is intended as a way for a GM to show a calendar like interface that maps to
- [Notes](./docs/Notes.md)
- [Configuring your Calendar](./docs/Configuration.md)
- [Macros](./docs/Macros.md)
- [Hooks](./docs/Hooks.md)

## Installing The Module

Expand Down
4 changes: 4 additions & 0 deletions __mocks__/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class Application {
close(){return Promise.resolve();}

activateListeners(data: any){}

setPosition(){}

_onResize(){}
}


Expand Down
4 changes: 2 additions & 2 deletions __mocks__/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const game = {
case SettingNames.ImportRan:
return false;
case SettingNames.YearConfiguration:
return {numericRepresentation: 0, prefix: '', postfix: '', showWeekdayHeadings: true};
return {numericRepresentation: 0, prefix: '', postfix: '', showWeekdayHeadings: true, firstWeekday: 0};
case SettingNames.MonthConfiguration:
return [[{name: '', numericRepresentation: 1, numberOfDays: 2, numberOfLeapYearDays: 2, intercalary: false, intercalaryInclude: false}]];
return [[{name: '', numericRepresentation: 1, numericRepresentationOffset: 0, numberOfDays: 2, numberOfLeapYearDays: 2, intercalary: false, intercalaryInclude: false}]];
case SettingNames.WeekdayConfiguration:
return [[{name: '', numericRepresentation: 0}]];
case SettingNames.LeapYearRule:
Expand Down
7 changes: 7 additions & 0 deletions __mocks__/hooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

const hooks = {
callAll: jest.fn()
};

//@ts-ignore
global.Hooks = hooks;
9 changes: 9 additions & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ Remove All Months Button | This button will remove all of the months from the li

This section displays all the weekdays that exist in the calendar. Weekdays are used to determine how wide the calendar display should be and how to make month days to each day of the week.

There are some global settings that affect all weekedays and they are as follows:

Setting | Description
-------- | ----------
Show Weekday Headings| If checked on the calendar view a row of weekday headings will show above the list of days. If unchecked these headings will be hidden.
Starting Week Day| This is used to select the day of the week that the first day of year 0 starts on. This can be used to help adjust the calendar so the days line up with official calendars.

The individual weekday settings are listed below:

Setting | Description
-------- | ----------
Weekday Name | These text boxes for each weekday allow you to change the name of an existing weekday.
Expand Down
165 changes: 165 additions & 0 deletions docs/Hooks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Hooks

Here are all the hooks that Simple Calendar emits and when they are emitted.

## How to Listen for a Hook

The global Simple Calendar object comes with a variable called hooks which will list all the available hooks that can be listened for.

Example:
```javascript
SimpleCalendar.Hooks.DateTimeChange
```

The current hooks that are emitted are:

Hook Name|Value|Description
---------|------|----------
DateTimeChange|`"simple-calendar-date-time-change"`|This hook is emitted any time the current date is updated.

## Date/Time Change

### When it is emitted
This hook is emitted any time the current date is updated. The current date can be updated by several means:

- When the GM clicks on the "[Set Current Date](./docs/UpdatingDateTime.md#date-controls)" button after adjusting the current date.
- When the [Set Date/Time macro](./docs/Macros.md#set-date-and-time) is called.
- When the [Change Date/Time macro](./docs/Macros.md#change-date-time) is called.
- When importing settings from [about-time](./docs/Configuration.md#about-time) or [Calendar/Weather](./docs/Configuration.md#calendarweather).
- When the [game world time](./docs/Configuration.md#game-world-time-integration) has changed and Simple Calendar is configured to update when that changes.

### What is passed

When this hook is emitted it will pass a data object that contains information about the new current day. The object will have these top level properties:

Property Name|Default Value|Description
-------------|-------------|------------
year|`{}` - Empty Object|This property will contain all information about the current year.<br/>For a breakdown of that information [see below](#year-properties).
month|`{}` - Empty Object|This property will contain all information about the current month.<br/>For a breakdown of that information [see below](#month-properties).
day|`{}` - Empty Object|This property will contain all information about the current day.<br/>For a breakdown of that information [see below](#day-properties).
time|`{}` - Empty Object|This property will contain all information about the current time.<br/>For a breakdown of that information [see below](#time-properties).
season|`{}` - Empty Object|This property will contain all information about the current season.<br/>For a breakdown of that information [see below](#season-properties).
moons|`[]` - Empty Array|This property will contain all information about the current moons.<br/>For a breakdown of that information [see below](#moon-properties).


#### Year Properties

Property Name|Value Type|Description
-------------|-------------|------------
number|number|This is the current years numerical representation.
prefix|string|This is the text that appears before the years numerical representation.
postfix|string|This is the test that appears after the years numerical representation.
isLeapYear|boolean|If this year is a leap year.

#### Month Properties

Property Name|Value Type|Description
-------------|-------------|------------
number|number|The months numerical representation.
name|string|The name of the month.
numberOfDays|number|How many days are in this month.
numberOfLeapYearDays|number|How many days are in this month during a leap year.
intercalary|boolean|If this month is considered an intercalary month or not.

#### Day Properties

Property Name|Value Type|Description
-------------|-------------|------------
number|number|The days numerical representation.

#### Time Properties

Property Name|Value Type|Description
-------------|-------------|------------
hour|string|The number of hours into the day it currently is. This result is 0 padded.
minute|string|The number of minutes into the day it currently is. This result is 0 padded.
second|string|The number of seconds into the day it currently is. This result is 0 padded.

#### Season Properties

Property Name|Value Type|Description
-------------|-------------|------------
name|string|The name of the season.
color|string|The hex color representation of the season.

#### Moon Properties

The moon properties is an array of moon objects, one for every moon in the calendar. The moon object is detailed below:

Property Name|Value Type|Description
-------------|-------------|------------
name|string|The name of the moon.
color|string|The hex color representation of the moon.
cycleLength|number|The number of calendar days for 1 cycle of the moon.
cycleDayAdjust|number|A entered adjustment used when calculating the current day of a cycle.
currentPhase|object|An object containing details about the phase the moon is in on this day.

#### Moon Phase Properties

Property Name|Value Type|Description
-------------|-------------|------------
name|string|The name of this moon phase.
icon|string|The css class associated with this moons phase to give the proper icon.
length|number|How many days of the cycle this phase lasts.
singleDay|boolean|If this phase should only happen on one day.


### Examples

#### Hooking to

This is an example of how to listen for the hook:

```javascript
Hooks.on(SimpleCalendar.Hooks.DateTimeChange, (data) => {
console.log(data);
});
```

#### Response Data

This is an example of the data that is passed with this hook:

```javascript
{
"year": {
"number": 2021,
"prefix": "",
"postfix": "",
"isLeapYear": false
},
"month": {
"name": "April",
"number": 4,
"intercalary": false,
"numberOfDays": 30,
"numberOfLeapYearDays": 30
},
"day": {
"number": 13
},
"time": {
"hour": "00",
"minute": "00",
"second": "56"
},
"season": {
"name": "Spring",
"color": "#fffce8"
},
"moons": [
{
"name": "Moon",
"color": "#ffffff",
"cycleLength": 29.53059,
"cycleDayAdjust": 0.5,
"currentPhase": {
"name": "Waxing Crescent",
"length": 6.3826,
"icon": "waxing-crescent",
"singleDay": false
}
}
]
}
```
Loading

0 comments on commit 39d6244

Please sign in to comment.