Skip to content

Commit

Permalink
Merge pull request #159 from vigoren/develop
Browse files Browse the repository at this point in the history
v1.3.0
  • Loading branch information
vigoren authored Jul 14, 2021
2 parents 1f5f5c2 + c3a93b2 commit b690cad
Show file tree
Hide file tree
Showing 61 changed files with 6,378 additions and 1,860 deletions.
57 changes: 57 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
# Change Log

## v1.3.0 - Note Improvements

### Notes

This update is mainly around notes and improving the experience around adding, editing and viewing them. The notable improvements/changes to notes are:

#### Functional Changes

- Notes can now span more than 1 day.
- Notes can now have a start and end time associated with them.
- Added a built-in Date/Time selector. This is a new input type that will show a calendar where you can choose a day, or range of days for the note a well as add a start/end time for the note.
- Notes can now be ordered on a day. By default, notes are ordered by starting time but can be adjusted for a custom order.

#### New Configuration Options

- Added a new setting to allow players to order notes on a day or not.
- Added the ability to specify note categories with unique labels and colors. These can be applied to a note to help distinguish different types of notes.

#### Visual Changes

- Refreshed the look of the note list.
- Added an indicator to the note list for GMs if the note is visible to the players or not.
- Added a label to the note list for the time the note takes place at.
- Added a label to the note list for who wrote the note.
- Any custom note categories associated with the note will also be shown.
- Changed the dialog's behaviour so that it will attempt to size itself to fit the content of the note appropriately.

### Quality of Life Changes

- Added a button to the module settings list that will open Simple Calendars configuration window.
- Changed the default "Show Clock" option so that new installs will show the clock right away. The clock can still be disabled by unchecking that option.
- Changed the default for the "Game World Integration" from None to Mixed. This only affects new installs of the module.

### API Changes

- Fixed a bug with the API getCurrentSeason function where the last season would always be returned.
- Additional information about the Season is returned for the api functions `getCurrentSeason`, `getAllSeasons` and `timestampToDate`:
- startingMonth: The month index the season starts on.
- startingDay: The day index of the starting month the season starts on.
- Fixed a bug with the API function `timestampPlusInterval` where in PF2E systems the returned value would be ahead by 1 day.

### Bug Fixes

- Fixed a bug where the [Moerills Expandable Markdown Editor](https://www.foundryvtt-hub.com/package/markdown-editor/) would not load properly when adding/editing notes.
- Fixed a bug where on new installs the default month and weekday names would not load correctly.
- Added a temporary "fix" to help with the weirdness that happens when running the latest version of Calendar/Weather. This "fix" will go away once Calendar/Weather has finished their integration with Simple Calendar. Some things to note about the changes:
- Any updates to the calendar structure (changing or months, season or moons) done within the Calendar/Weather interface will now require you to go into Simple Calendars configuration and re-import the calendar to have the changes reflected there.
- I have run tests with PF2E worlds and everything should stay in sync with that systems world clock.
- Calendar/Weather, about-time and Simple Calendar play better together but they will be their best when Calendar/Weather has finished its rewrite to properly utilize Simple Calendars API.
- Fixed an issued with importing events from Calendar/Weather.
- In some instances Calendar/Weather Events don't have their month saved properly, in these instances the month is set to the first month of the year.

### Translations

- German Translation updates from [BlueSkyBlackBird](https://github.com/BlueSkyBlackBird) and [MasterZelgadis](https://github.com/MasterZelgadis), thanks!

## v1.2.113 - API Changes

- Updated the timestampToDate function's return values. The result now contains a display object that contains all the different display strings for the passed in timestamp.
Expand All @@ -8,6 +64,7 @@
- Added a function SimpleCalendar.api.getCurrentSeason() that returns details about the season for the current date.
- Added a function SimpleCalendar.api.getAllSeasons() that returns details for every configured season in Simple Calendar.
- Fixed a bug when importing from Calendar/weather where the hours per day would end up being undefined.
- Added the ability to use the new Date Selector input type to other modules/systems through Simple Calendars API. [Read more here!](./docs/API.md)

## v1.2.107 - Calendar Configuration Import/Export, API Changes, Bug Fixes

Expand Down
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,39 @@ A simple calendar module for [FoundryVTT](https://foundryvtt.com/) that is syste
This module allows you to create a calendar with any number of months per year, any number of days per month and customizable hours, minutes and seconds for your game world.
It is intended as a way for a GM to show a calendar like interface that maps to their in game world.

## Contents

- [Features](#features)
- [Installation](#installing-the-module)
- [Compatible Modules](#compatible-modules)
- [Accessing and using the calendar](./docs/UsingTheCalendar.md)
- [Configuring your Calendar](./docs/Configuration.md)
- [Changing the date and time](./docs/UpdatingDateTime.md)
- [Notes](./docs/Notes.md)
- [Hooks](./docs/Hooks.md)
- [API (For other modules and systems)](./docs/API.md)
- [Translations](#translations)

## Features
Simple Calendar has a number of features that make it a great time keeping tool for your games!

### For GMs
* Complete customization of the calendar to meet your worlds needs:
* Set the year as well as add any prefix or postfix to the years name.
* Complete customization of the calendar to meet your worlds needs! Including the following functionality:
* Set the year as well as add any prefix or postfix or a custom name for the year.
* Define how many months in a year.
* Set a custom name, the number of days and days during a leap year (if applicable) for each month.
* Set a custom name, the number of days for each month.
* Choose if months are considered intercalary (fall outside normal months).
* Define how many days in a week and the name of each weekday.
* Set the number hours in a day, minutes in an hour and seconds in a minute.
* Set up your own Leap Year rules.
* Set up different seasons for your calendar and how they are displayed to the users.
* Set up your own custom moons.
* Or choose from a selection of [preset calendars](./docs/Configuration.md#predefined-calendars).
* Set and change the current day and time as your game story progresses or have it automatically advance based on real world time and passing combat rounds.
* 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.
* Add custom labels to notes to help distinguish the type of note.
* Set if the note is visible to players or just the GM.
* Support for repeating notes! They can repeat weekly, monthly or yearly.

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

Expand All @@ -50,17 +66,7 @@ It is intended as a way for a GM to show a calendar like interface that maps to

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

## Contents

- [Installation](#installing-the-module)
- [Compatible Modules](#compatible-modules)
- [Accessing and using the calendar](./docs/UsingTheCalendar.md)
- [Changing the date and time](./docs/UpdatingDateTime.md)
- [Notes](./docs/Notes.md)
- [Configuring your Calendar](./docs/Configuration.md)
- [Macros](./docs/Macros.md)
- [Hooks](./docs/Hooks.md)
- [Translations](#translations)

## Installing The Module

Expand Down Expand Up @@ -89,7 +95,7 @@ Simple Calendar is available in languages other than English thanks to the follo

Language|Translator(s)
--------|----------
German (de)|[MasterZelgadis](https://github.com/MasterZelgadis)
German (de)|[MasterZelgadis](https://github.com/MasterZelgadis) <br/> [BlueSkyBlackBird](https://github.com/BlueSkyBlackBird)
Traditional Chinese (zh)|[benwater12](https://github.com/benwater12)
Spanish (es)|[areymoreno](https://github.com/areymoreno)
Korean (ko)|[drdwing](https://github.com/drdwing)
Expand Down
2 changes: 1 addition & 1 deletion __mocks__/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Event{
this.currentTarget.classList.add('next');
}
target = document.createElement('input');
currentTarget = document.createElement('a')
currentTarget = document.createElement('a');
}

//@ts-ignore
Expand Down
1 change: 1 addition & 0 deletions __mocks__/form-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class FormApplication extends Application{
activateEditor(a: string){}
saveEditor(a: string){}
bringToTop(){}
maximize(){return Promise.resolve();}
}

// @ts-ignore
Expand Down
15 changes: 12 additions & 3 deletions __mocks__/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,22 @@ const user: User = {
viewedScene: '',
avatar: '',
//character: {},
// @ts-ignore
permissions: [],
isTrusted: false,
isGM: false,
isSelf: true,
// @ts-ignore
can: jest.fn((permission: string) => {return false;}),
hasPermission: jest.fn((permission: string) => {return false;}),
// @ts-ignore
hasRole: jest.fn((role: string) => {return true;}),
// @ts-ignore
isRole: jest.fn((role: string) => {return false;}),
// @ts-ignore
setPermission: jest.fn((premission: string, allowed: boolean) => {}),
assignHotbarMacro: jest.fn((macro: Macro | null, slot: number, {fromSlot}: { fromSlot?: number }): Promise<User> => { return Promise.resolve(user);}),
assignHotbarMacro: jest.fn((macro: Macro | null, slot: string | number, {fromSlot}: { fromSlot: number }): Promise<User> => { return Promise.resolve(user);}),
// @ts-ignore
getHotbarMacros: jest.fn((page?: number): Macro[] => {return [];})
};

Expand Down Expand Up @@ -60,17 +66,20 @@ const game = {
return {year: 0, month: 1, day: 2, seconds: 3};
case SettingNames.Notes:
return [[{year: 0, month: 1, day: 2, title:'', content:'', author:'', playerVisible: false, id: 'abc123'}]];
case SettingNames.NoteCategories:
return [];
case SettingNames.GeneralConfiguration:
return {gameWorldTimeIntegration: GameWorldTimeIntegrations.None, showClock: false, pf2eSync: true, permissions: {viewCalendar: {player:true, trustedPlayer: true, assistantGameMaster: true, users: undefined}, addNotes:{player:false, trustedPlayer: false, assistantGameMaster: false, users: undefined}, changeDateTime:{player:false, trustedPlayer: false, assistantGameMaster: false, users: undefined}}}
return {gameWorldTimeIntegration: GameWorldTimeIntegrations.None, showClock: false, pf2eSync: true, permissions: {viewCalendar: {player:true, trustedPlayer: true, assistantGameMaster: true, users: undefined}, addNotes:{player:false, trustedPlayer: false, assistantGameMaster: false, users: undefined}, reorderNotes:{player:false, trustedPlayer: false, assistantGameMaster: false}, changeDateTime:{player:false, trustedPlayer: false, assistantGameMaster: false, users: undefined}}}
case SettingNames.TimeConfiguration:
return {hoursInDay:0, minutesInHour: 1, secondsInMinute: 2, gameTimeRatio: 3, unifyGameAndClockPause: false, updateFrequency: 1};
case SettingNames.SeasonConfiguration:
return [[{name:'', startingMonth: 1, startingDay: 1, color: '#ffffff', customColor: ''}]];
return [[{name:'', startingMonth: 1, startingDay: 1, color: '#ffffff'}]];
case SettingNames.MoonConfiguration:
return [[{"name":"","cycleLength":0,"firstNewMoon":{"yearReset":"none","yearX":0,"year":0,"month":1,"day":1},"phases":[{"name":"","length":3.69,"icon":"new","singleDay":true}],"color":"#ffffff","cycleDayAdjust":0}]];
}
}),
register: jest.fn((moduleName: string, settingName: string, data: any) => {}),
registerMenu: jest.fn(),
set: jest.fn((moduleName: string, settingName: string, data: any) => {return Promise.resolve(true);})
},
time: {
Expand Down
14 changes: 13 additions & 1 deletion __mocks__/handlebars.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@

class ss{
v: string;
constructor(v: string) {
this.v = v;
}

toString() {
return this.v.toString();
}
}

const handlebars = {
registerHelper: jest.fn((name: string, fn: Function) => {})
registerHelper: jest.fn((name: string, fn: Function) => {}),
SafeString: ss
};

// @ts-ignore
Expand Down
115 changes: 99 additions & 16 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,77 @@ SimpleCalendar.api.dateToTimestamp({}); //Returns the timestamp for the current
SimpleCalendar.api.dateToTimestamp({year: 2021, month: 0, day: 0, hour: 1, minute: 1, second: 0}); //Returns 1609462860
```

## `SimpleCalendar.api.getAllSeasons()`

Gets all the seasons for the calendar.

### Returns

This function returns an array of [Season objects](#simplecalendarapigetcurrentseason).

### Examples
```javascript
SimpleCalendar.api.getAllSeasons();
/*
Returns an array like this, assuming the Gregorian Calendar
[
{
color: "#fffce8",
name: "Spring",
startingDay: 19,
startingMonth: 2
},
{
color: "#f3fff3",
name: "Summer",
startingDay: 19,
startingMonth: 5
},
{
color: "#fff7f2",
name: "Fall",
startingDay: 21,
startingMonth: 8
},
{
color: "#f2f8ff",
name: "Winter",
startingDay: 20,
startingMonth: 11
}
]
*/
```

## `SimpleCalendar.api.getCurrentSeason()`

Gets the details about the season for the current date of the calendar.

### Returns

This function returns a Season object with the following properties:

Property|Type|Default Value|Description
---------|-----|-------------|-----------
name|String|''|The name of the season.
color|String|#ffffff|The color associated with this season.
startingDay|Number|1|The day index of the month that the season starts on.
startingMonth|Number|1|The month index that the season starts on.

### Examples

```javascript
SimpleCalendar.api.getCurrentSeason();
/* Returns an object like this
{
name: "Summer",
color:"#f3fff3",
startingDay: 19,
startingMonth: 5
}
*/
```

## `SimpleCalendar.api.isPrimaryGM()`

Returns if the current user is considered the primary GM or not.
Expand Down Expand Up @@ -353,22 +424,34 @@ let scDate = SimpleCalendar.api.timestampToDate(1622505600);
console.log(scDate);
/* This is what the returned object will look like
{
currentSeason: {name: "Spring", color: "#fffce8"}
day: 0
dayDisplay: 1
dayOfTheWeek: 2
dayOffset: 0
hour: 0
minute: 0
month: 5
monthName: "June"
second: 0
showWeekdayHeadings: true
weekdays: (7) ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
year: 2021
yearName: ""
yearPostfix: ""
yearPrefix: ""
currentSeason: {color: "#fffce8", startingMonth: 3, startingDay: 20, name: "Spring"},
day: 0,
dayDisplay: "1",
dayOfTheWeek: 2,
dayOffset: 0,
display: {
day: "1",
daySuffix: "st",
month: "6",
monthName: "June",
time: "21:03:35",
weekday: "Tuesday",
year: "2021",
yearName: "",
yearPostfix: "",
yearPrefix: "",
},
hour: 0,
minute: 0,
month: 5,
monthName: "June",
second: 0,
showWeekdayHeadings: true,
weekdays: (7) ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
year: 2021,
yearName: "",
yearPostfix: "",
yearPrefix: "",
yearZero: 1970
}
*/
Expand Down
7 changes: 4 additions & 3 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ This tab contains the settings for creating and interacting with notes.
Setting | Description
-------- | ----------
Note Default Player Visibility | For new notes, if by default the player visibility option is checked or not.

Players Can Add Notes | If checked players will be allowed to add their own notes to the calendar.
Players Can Re-Order Notes | If checked players will be allowed to re-order the notes on a day.


## Year Settings
Expand Down Expand Up @@ -202,18 +203,18 @@ Hours in a Day | This defines how many hours make up a single day.
Minutes in a Hour | This defines how many minutes make up a single hour.
Seconds in a Minute | This defines how many seconds make up a single minute.


### Clock Settings

Settings specific to the clock portion of the calendar.

Setting | Description
-------- | ----------
Show Clock | This setting is used to show the time clock below the calendar or to hide it. Not all games care about keeping track of the specific time of day so this is a great option to disable that part. Hiding the clock also hides the controls for changing hours, minutes, seconds.
Show Clock | This setting is used to show the time clock below the calendar or to hide it. Not all games care about keeping track of the specific time of day so this is a great option to disable that part. Hiding the clock also hides the controls for changing hours, minutes, seconds.
Game Seconds Per Real Life Seconds | This is used to determine how quickly game time advances when running the Simple Calendar clock. With a value of 1, for every real life seconds 1 second passes in the game. With a value of 2 for every 1 real life seconds 2 seconds pass in game. This does support decimals for more specific control.
Update Frequency | THis determines how often (in seconds) the clock is updated. By default the clock updates every second but this can be changed to less frequently if that is desired.
Unify Clock Start/Pause With Game Pause | This ties the clocks start/pause button with the game pause state. Starting the clock will unpause the game, pausing the clock will pause the game. The opposite is true as well.


## Moon Settings

This section allows the GM to configure the different moons of the world so that their cycles display on the calendar.
Expand Down
6 changes: 3 additions & 3 deletions docs/Macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
Here are all the exposed functions that can be used when creating a macro.

## Open Simple Calendar
This macro has been depreciated. Please use the new [showCalendar](./docs/API.md#simplecalendarapishowcalendardate) function.
This macro has been depreciated. Please use the new [showCalendar](./API.md#simplecalendarapishowcalendardate) function.

## Set Date and Time
This macro has been depreciated. Please use the new [setDate](./docs/API.md#simplecalendarapisetdatedate) function.
This macro has been depreciated. Please use the new [setDate](./API.md#simplecalendarapisetdatedate) function.

## Change Date Time

This macro has been depreciated. Please use the new [changeDate](./docs/API.md#simplecalendarapichangedateinterval) function.
This macro has been depreciated. Please use the new [changeDate](./API.md#simplecalendarapichangedateinterval) function.
Loading

0 comments on commit b690cad

Please sign in to comment.