@drincs/nqtr 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +122 -16
- package/dist/index.d.ts +122 -16
- package/dist/index.js +86 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113,6 +113,7 @@ var TimeManager = class _TimeManager {
|
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Get time settings
|
|
116
|
+
* @default {}
|
|
116
117
|
*/
|
|
117
118
|
static get settings() {
|
|
118
119
|
let settings = import_pixi_vn.GameStorageManager.getVariable(TIME_SETTINGS_KEY) || {};
|
|
@@ -235,12 +236,13 @@ var TimeManager = class _TimeManager {
|
|
|
235
236
|
/**
|
|
236
237
|
* Get the current week day name. If the week days names are not defined, then it will return undefined.
|
|
237
238
|
* For example, if the week days names are ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'] and the current day is 10, then the result will be 'Thursday'.
|
|
239
|
+
* @default ""
|
|
238
240
|
*/
|
|
239
241
|
static get currentDayName() {
|
|
240
242
|
let weekDayNumber = _TimeManager.currentWeekDayNumber - 1;
|
|
241
243
|
if (weekDayNumber >= _TimeManager.weekDaysNames.length) {
|
|
242
244
|
console.warn(`[NQTR] Week day name is not defined for day ${weekDayNumber}`, _TimeManager.weekDaysNames);
|
|
243
|
-
return
|
|
245
|
+
return "";
|
|
244
246
|
}
|
|
245
247
|
return _TimeManager.weekDaysNames[weekDayNumber];
|
|
246
248
|
}
|
|
@@ -270,7 +272,7 @@ var TimeManager = class _TimeManager {
|
|
|
270
272
|
}
|
|
271
273
|
}
|
|
272
274
|
}
|
|
273
|
-
return
|
|
275
|
+
return _TimeManager.timeSlots.length - 1;
|
|
274
276
|
}
|
|
275
277
|
/**
|
|
276
278
|
* This function will increase the current hour by the given time spent.
|
|
@@ -316,6 +318,10 @@ var TimeManager = class _TimeManager {
|
|
|
316
318
|
|
|
317
319
|
// src/classes/Activity.ts
|
|
318
320
|
var ActivityStoredAbstract = class {
|
|
321
|
+
/**
|
|
322
|
+
* @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.
|
|
323
|
+
* @param props The activity properties.
|
|
324
|
+
*/
|
|
319
325
|
constructor(onRun, props) {
|
|
320
326
|
this.defaultName = props.name;
|
|
321
327
|
this.defaultFromHour = props.fromHour;
|
|
@@ -327,36 +333,54 @@ var ActivityStoredAbstract = class {
|
|
|
327
333
|
this._icon = props.icon;
|
|
328
334
|
this._onRun = onRun;
|
|
329
335
|
}
|
|
336
|
+
/**
|
|
337
|
+
* The name
|
|
338
|
+
*/
|
|
330
339
|
get name() {
|
|
331
340
|
return this.getStorageProperty("name") || this.defaultName || "";
|
|
332
341
|
}
|
|
333
342
|
set name(value) {
|
|
334
343
|
this.setStorageProperty("name", value);
|
|
335
344
|
}
|
|
345
|
+
/**
|
|
346
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
347
|
+
*/
|
|
336
348
|
get fromHour() {
|
|
337
349
|
return this.getStorageProperty("fromHour") || this.defaultFromHour || TimeManager.minDayHours;
|
|
338
350
|
}
|
|
339
351
|
set fromHour(value) {
|
|
340
352
|
this.setStorageProperty("fromHour", value);
|
|
341
353
|
}
|
|
354
|
+
/**
|
|
355
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
356
|
+
*/
|
|
342
357
|
get toHour() {
|
|
343
358
|
return this.getStorageProperty("toHour") || this.defaultToHour || TimeManager.maxDayHours + 1;
|
|
344
359
|
}
|
|
345
360
|
set toHour(value) {
|
|
346
361
|
this.setStorageProperty("toHour", value);
|
|
347
362
|
}
|
|
363
|
+
/**
|
|
364
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
365
|
+
*/
|
|
348
366
|
get fromDay() {
|
|
349
367
|
return this.getStorageProperty("fromDay") || this.defaultFromDay;
|
|
350
368
|
}
|
|
351
369
|
set fromDay(value) {
|
|
352
370
|
this.setStorageProperty("fromDay", value);
|
|
353
371
|
}
|
|
372
|
+
/**
|
|
373
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
374
|
+
*/
|
|
354
375
|
get toDay() {
|
|
355
376
|
return this.getStorageProperty("toDay") || this.defaultToDay;
|
|
356
377
|
}
|
|
357
378
|
set toDay(value) {
|
|
358
379
|
this.setStorageProperty("toDay", value);
|
|
359
380
|
}
|
|
381
|
+
/**
|
|
382
|
+
* Whether is disabled.
|
|
383
|
+
*/
|
|
360
384
|
get disabled() {
|
|
361
385
|
let value = this.getStorageProperty("disabled") || this.defaultDisabled;
|
|
362
386
|
if (typeof value === "string") {
|
|
@@ -367,6 +391,9 @@ var ActivityStoredAbstract = class {
|
|
|
367
391
|
set disabled(value) {
|
|
368
392
|
this.setStorageProperty("disabled", value);
|
|
369
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
396
|
+
*/
|
|
370
397
|
get hidden() {
|
|
371
398
|
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
372
399
|
return true;
|
|
@@ -386,18 +413,32 @@ var ActivityStoredAbstract = class {
|
|
|
386
413
|
set hidden(value) {
|
|
387
414
|
this.setStorageProperty("hidden", value);
|
|
388
415
|
}
|
|
416
|
+
/**
|
|
417
|
+
* The icon element.
|
|
418
|
+
*/
|
|
389
419
|
get icon() {
|
|
390
420
|
return this._icon;
|
|
391
421
|
}
|
|
422
|
+
/**
|
|
423
|
+
* The function that is called when the activity is runned.
|
|
424
|
+
*/
|
|
392
425
|
get onRun() {
|
|
393
426
|
return () => this._onRun(this);
|
|
394
427
|
}
|
|
428
|
+
/**
|
|
429
|
+
* Whether the activity is a deadline.
|
|
430
|
+
* @returns Whether the activity is a deadline.
|
|
431
|
+
*/
|
|
395
432
|
isExpired() {
|
|
396
433
|
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
397
434
|
return true;
|
|
398
435
|
}
|
|
399
436
|
return false;
|
|
400
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Export the activity properties.
|
|
440
|
+
* @returns The activity properties.
|
|
441
|
+
*/
|
|
401
442
|
export() {
|
|
402
443
|
return {
|
|
403
444
|
name: this.getStorageProperty("name") || this.defaultName,
|
|
@@ -412,6 +453,11 @@ var ActivityStoredAbstract = class {
|
|
|
412
453
|
}
|
|
413
454
|
};
|
|
414
455
|
var ActivityModel = class {
|
|
456
|
+
/**
|
|
457
|
+
* @param id The activity id, that must be unique.
|
|
458
|
+
* @param onRun The function that is called when the activity is runned. Have 2 parameters: the runned activity and the yourParams object, that is an object with the parameters that you want to pass to the onRun function.
|
|
459
|
+
* @param props The activity properties.
|
|
460
|
+
*/
|
|
415
461
|
constructor(id, onRun, props) {
|
|
416
462
|
this._id = id;
|
|
417
463
|
this._name = props.name;
|
|
@@ -424,30 +470,54 @@ var ActivityModel = class {
|
|
|
424
470
|
this._icon = props.icon;
|
|
425
471
|
this._onRun = onRun;
|
|
426
472
|
}
|
|
473
|
+
/**
|
|
474
|
+
* The activity id, that is unique.
|
|
475
|
+
*/
|
|
427
476
|
get id() {
|
|
428
477
|
return this._id;
|
|
429
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* The name
|
|
481
|
+
*/
|
|
430
482
|
get name() {
|
|
431
483
|
return this._name;
|
|
432
484
|
}
|
|
485
|
+
/**
|
|
486
|
+
* The hour when the activity starts. If the activity is not started yet, it will be hidden.
|
|
487
|
+
*/
|
|
433
488
|
get fromHour() {
|
|
434
489
|
return this._fromHour;
|
|
435
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* The hour when the activity ends. If the activity is ended yet, it will be hidden.
|
|
493
|
+
*/
|
|
436
494
|
get toHour() {
|
|
437
495
|
return this._toHour;
|
|
438
496
|
}
|
|
497
|
+
/**
|
|
498
|
+
* The day when the activity starts. If the activity is not started yet, it will be hidden.
|
|
499
|
+
*/
|
|
439
500
|
get fromDay() {
|
|
440
501
|
return this._fromDay;
|
|
441
502
|
}
|
|
503
|
+
/**
|
|
504
|
+
* The day when the activity ends. If the activity is ended yet, it will be deleted or hidden.
|
|
505
|
+
*/
|
|
442
506
|
get toDay() {
|
|
443
507
|
return this._toDay;
|
|
444
508
|
}
|
|
509
|
+
/**
|
|
510
|
+
* Whether is disabled.
|
|
511
|
+
*/
|
|
445
512
|
get disabled() {
|
|
446
513
|
if (typeof this._disabled === "string") {
|
|
447
514
|
return (0, import_pixi_vn2.getFlag)(this._disabled);
|
|
448
515
|
}
|
|
449
516
|
return this._disabled;
|
|
450
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* Whether is hidden. If the activity is not started yet, it will be hidden.
|
|
520
|
+
*/
|
|
451
521
|
get hidden() {
|
|
452
522
|
if (this.fromDay && this.fromDay > TimeManager.currentDay) {
|
|
453
523
|
return true;
|
|
@@ -460,18 +530,32 @@ var ActivityModel = class {
|
|
|
460
530
|
}
|
|
461
531
|
return this._hidden;
|
|
462
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* The icon element.
|
|
535
|
+
*/
|
|
463
536
|
get icon() {
|
|
464
537
|
return this._icon;
|
|
465
538
|
}
|
|
539
|
+
/**
|
|
540
|
+
* The function that is called when the activity is runned.
|
|
541
|
+
*/
|
|
466
542
|
get onRun() {
|
|
467
543
|
return () => this._onRun(this);
|
|
468
544
|
}
|
|
545
|
+
/**
|
|
546
|
+
* Whether the activity is a deadline.
|
|
547
|
+
* @returns Whether the activity is a deadline.
|
|
548
|
+
*/
|
|
469
549
|
isDeadline() {
|
|
470
550
|
if (this.toDay && this.toDay <= TimeManager.currentDay) {
|
|
471
551
|
return true;
|
|
472
552
|
}
|
|
473
553
|
return false;
|
|
474
554
|
}
|
|
555
|
+
/**
|
|
556
|
+
* Export the activity properties.
|
|
557
|
+
* @returns The activity properties.
|
|
558
|
+
*/
|
|
475
559
|
export() {
|
|
476
560
|
return {
|
|
477
561
|
name: this._name,
|