From 83ddab5f82d289b6388c1e5a88c3de8c37d4fe1e Mon Sep 17 00:00:00 2001 From: tagazox Date: Mon, 7 Oct 2019 14:26:54 +0200 Subject: [PATCH 01/11] Ajout du scan de l'alignement --- electron/settings/settings-default.ts | 1 + electron/settings/settings.interface.ts | 1 + locale/en.json | 1 + locale/es.json | 1 + locale/fr.json | 1 + locale/it.json | 1 + package-lock.json | 28 +++- src/app/components/game/game.component.ts | 4 + src/app/core/mods/aligement/alignement.ts | 84 +++++++++++ .../core/mods/aligement/alignementUIBar.ts | 131 ++++++++++++++++++ .../mods/aligement/alignementUIContainer.ts | 108 +++++++++++++++ src/app/core/mods/aligement/temp | 58 ++++++++ src/app/core/mods/aligement/temp2.js | 8 ++ src/app/core/mods/shortcuts/shortcuts.ts | 10 +- src/app/core/service/settings.service.ts | 11 ++ .../shortcuts/other/other.component.html | 5 +- 16 files changed, 444 insertions(+), 9 deletions(-) create mode 100644 src/app/core/mods/aligement/alignement.ts create mode 100644 src/app/core/mods/aligement/alignementUIBar.ts create mode 100644 src/app/core/mods/aligement/alignementUIContainer.ts create mode 100644 src/app/core/mods/aligement/temp create mode 100644 src/app/core/mods/aligement/temp2.js diff --git a/electron/settings/settings-default.ts b/electron/settings/settings-default.ts index 930d1410..e5ceceab 100644 --- a/electron/settings/settings-default.ts +++ b/electron/settings/settings-default.ts @@ -45,6 +45,7 @@ export const SettingsDefault: SettingsInterface = { diver: { end_turn: "backspace", open_chat: "return", + alignement_scan: "ctrl+s", active_open_menu: true, open_menu: "", go_up: "ctrl+up", diff --git a/electron/settings/settings.interface.ts b/electron/settings/settings.interface.ts index ac8f72e8..cae85446 100644 --- a/electron/settings/settings.interface.ts +++ b/electron/settings/settings.interface.ts @@ -32,6 +32,7 @@ export interface SettingsInterface { diver: { end_turn: string; open_chat: string; + alignement_scan: string, active_open_menu: boolean; open_menu: string; go_up: string; diff --git a/locale/en.json b/locale/en.json index ef4377f4..c1d92f17 100644 --- a/locale/en.json +++ b/locale/en.json @@ -217,6 +217,7 @@ "header": "Miscellaneous", "end-turn": "End your turn / Ready (fight)", "open-chat": "Open the chat", + "alignement_scan":"Scan player alignements", "active-open-menu": "Open menu when no window is open (ECHAP)", "open-menu": "Open the menu", "go_up": "Go to Upper Map", diff --git a/locale/es.json b/locale/es.json index 476500f5..193ac1da 100644 --- a/locale/es.json +++ b/locale/es.json @@ -213,6 +213,7 @@ "header": "Diverso", "end-turn": "Saltar su torno / Listo (combate)", "open-chat": "Abrir el chat", + "alignement_scan":"Escanear alineaciones de reproductores", "active-open-menu": "Apri menu quando nessuna finestra è aperta (ECHAP)", "open-menu": "Abre el menu", "go_up": "Ir a Mapa Superior", diff --git a/locale/fr.json b/locale/fr.json index c3fc70a1..0b590d99 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -216,6 +216,7 @@ "header": "Divers", "end-turn": "Passer son tour / Prêt (combat)", "open-chat": "Ouvrir le chat", + "alignement_scan":"Scanner les alignements des joueurs", "active-open-menu": "Ouvrir le menu lorsqu'aucune fenêtre n'est ouverte (ECHAP)", "open-menu": "Ouvrir le menu", "go_up" : "Aller à la carte du dessus", diff --git a/locale/it.json b/locale/it.json index d5f57b0a..6e8011f7 100644 --- a/locale/it.json +++ b/locale/it.json @@ -217,6 +217,7 @@ "header": "Varie", "end-turn": "Finisci il turno / Pronto (combattimenti)", "open-chat": "Apri la chat", + "alignement_scan": "Scansione degli allineamenti dei giocatori", "active-open-menu": "Apri menu quando nessuna finestra è aperta (ECHAP)", "open-menu": "Apri il menu", "go_up": "Vai alla Mappa superiore", diff --git a/package-lock.json b/package-lock.json index 19b4977f..945a4e75 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5770,11 +5770,13 @@ }, "balanced-match": { "version": "1.0.0", - "bundled": true + "bundled": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5787,15 +5789,18 @@ }, "code-point-at": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "concat-map": { "version": "0.0.1", - "bundled": true + "bundled": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", - "bundled": true + "bundled": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -5898,7 +5903,8 @@ }, "inherits": { "version": "2.0.3", - "bundled": true + "bundled": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -5908,6 +5914,7 @@ "is-fullwidth-code-point": { "version": "1.0.0", "bundled": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5920,17 +5927,20 @@ "minimatch": { "version": "3.0.4", "bundled": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } }, "minimist": { "version": "0.0.8", - "bundled": true + "bundled": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5947,6 +5957,7 @@ "mkdirp": { "version": "0.5.1", "bundled": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -6019,7 +6030,8 @@ }, "number-is-nan": { "version": "1.0.1", - "bundled": true + "bundled": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -6029,6 +6041,7 @@ "once": { "version": "1.4.0", "bundled": true, + "optional": true, "requires": { "wrappy": "1" } @@ -6134,6 +6147,7 @@ "string-width": { "version": "1.0.2", "bundled": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", diff --git a/src/app/components/game/game.component.ts b/src/app/components/game/game.component.ts index 8d3dc950..1aab2994 100644 --- a/src/app/components/game/game.component.ts +++ b/src/app/components/game/game.component.ts @@ -21,6 +21,7 @@ import { CssOverload } from "app/core/mods/cssOverload/cssOverload"; import { JsFixes } from "app/core/mods/jsFixes/jsFixes"; import { RapidExchange } from "app/core/mods/rapid-exchange/rapid-exchange"; import { HideShop } from "app/core/mods/hide-shop/hide-shop"; +import { Alignement } from "app/core/mods/aligement/alignement"; import { KeyboardInput } from "app/core/mods/keyboard-input/keyboard-input"; import { HttpClient } from '@angular/common/http'; import { HideMount } from "app/core/mods/hide-mount/hide-mount"; @@ -58,6 +59,7 @@ export class GameComponent implements AfterViewInit { private hideMount: HideMount; private partyInfo:PartyInfo; private mover: Mover; + private alignement: Alignement; constructor( private windowService: WindowService, private ipcRendererService: IpcRendererService, @@ -139,6 +141,7 @@ export class GameComponent implements AfterViewInit { if (this.hideMount) this.hideMount.reset(); if (this.partyInfo) this.partyInfo.reset(); if (this.mover) this.mover.reset(); + if (this.alignement) this.alignement.reset(); } } @@ -184,6 +187,7 @@ export class GameComponent implements AfterViewInit { this.keyboardInput = new KeyboardInput(this.game.window); this.partyInfo = new PartyInfo(this.game.window, this.settingsService.option.vip.general.party_info_pp, this.settingsService.option.vip.general.party_info_lvl, this.translate); this.mover = new Mover(this.game.window); + this.alignement = new Alignement(this.game.window); } } diff --git a/src/app/core/mods/aligement/alignement.ts b/src/app/core/mods/aligement/alignement.ts new file mode 100644 index 00000000..afd026ae --- /dev/null +++ b/src/app/core/mods/aligement/alignement.ts @@ -0,0 +1,84 @@ +import {Mods} from "../mods"; +import { Logger } from "app/core/electron/logger.helper"; +import { alignementUIContainer } from "./alignementUIContainer"; + +/** + * This mod add the possibility to show alignement + */ +export class Alignement extends Mods{ + + private AlignementBarContainer : HTMLDivElement; + private AlignementBar : HTMLDivElement; + private shieldBar : HTMLDivElement; + private lifePointsText : HTMLDivElement; + private container : alignementUIContainer; + + constructor (wGame: any | Window) { + super(wGame); + + //Side definition : + // 0 => neutre + // 1 => Bonta + // 2 => Brakmar + // + //Grade : + //0 = aussi les ailes cachés. + // de 0 à 10 + //Value Currently unknown + + + + + + let healthbarCss = document.createElement('style'); + healthbarCss.id = 'AlignementBarCss'; + healthbarCss.innerHTML = ` + .AlignementBarsContainer { + position: absolute; + top: 0; + left: 0; + pointer-events: none; + z-index: 1; + visibility: hidden; + } + + .AlignementBarContainer { + box-sizing: border-box; + border: 1px gray solid; + background-color: #222; + height: 6px; + width: 30px; + position: absolute; + border-radius: 3px; + overflow: hidden; + transition-duration: 500ms; + margin-top: 10px; + } + + .AlignementBar { + transition-duration: 300ms; + height: 100%; + width: 0%; + background-color: #333; + } + `; + this.wGame.document.getElementsByTagName('head')[0].appendChild(healthbarCss); + + } + public scan(){ + if(this.container!=null) + this.container.destroy(); + this.container = new alignementUIContainer(this.wGame); + this.container.show(); + setTimeout(() => { + this.container.destroy(); + }, 2000); + } + public reset() { + super.reset(); + if (this.container) this.container.destroy(); + let healthbarCss = this.wGame.document.getElementById('AlignementBarCss'); + if (healthbarCss && healthbarCss.parentElement) healthbarCss.parentElement.removeChild(healthbarCss); + } + +} diff --git a/src/app/core/mods/aligement/alignementUIBar.ts b/src/app/core/mods/aligement/alignementUIBar.ts new file mode 100644 index 00000000..f1285143 --- /dev/null +++ b/src/app/core/mods/aligement/alignementUIBar.ts @@ -0,0 +1,131 @@ +import { alignementUIContainer } from "./alignementUIContainer"; +import { Logger } from "app/core/electron/logger.helper"; +export class alignementUIBar { + + private fighter: any; + private wGame: any; + + private lifeBarContainer : HTMLDivElement; + private lifeBar : HTMLDivElement; + private container : alignementUIContainer; + + constructor(fighter: any, container: alignementUIContainer, wGame: any | Window){ + this.fighter = fighter; + this.wGame = wGame; + this.container = container; + + this.createBar(); + + } + + public getId(){ + return this.fighter.data.playerId; + } + + + + private createBar(){ + /* retrieve data */ + let life = 1; + let cellId = this.fighter.cellId; + let scenePos = this.wGame.isoEngine.mapRenderer.getCellSceneCoordinate(cellId); + let pos = this.wGame.isoEngine.mapScene.convertSceneToCanvasCoordinate(scenePos.x, scenePos.y); + + /* lifeBarContainer */ + this.lifeBarContainer = document.createElement('div'); + this.lifeBarContainer.id = 'fighterAlignementBarContainer' + this.fighter.data.playerId; + this.lifeBarContainer.className = 'AlignementBarContainer'; + + + + + /* lifeBar */ + this.lifeBar = document.createElement('div'); + this.lifeBar.id = 'fighterAlignementBar' +this.fighter.data.playerId; + this.lifeBar.className = 'AlignementBar'; + + let AlignementInfo = this.fighter.data.alignmentInfos; + switch (AlignementInfo.alignmentSide) { + case 0: + this.lifeBarContainer.style.borderColor = '#000'; + this.lifeBarContainer.style.backgroundColor = '#000'; + + this.lifeBar.style.borderColor = '#000'; + this.lifeBar.style.backgroundColor = '#000'; + break; + case 1: + this.lifeBarContainer.style.borderColor = '#0000FF'; + this.lifeBarContainer.style.backgroundColor = '#0000FF'; + + this.lifeBar.style.borderColor = '#0000FF'; + this.lifeBar.style.backgroundColor = '#0000FF'; + break; + case 2: + this.lifeBarContainer.style.borderColor = '#FF0000'; + this.lifeBarContainer.style.backgroundColor = '#FF0000'; + + this.lifeBar.style.borderColor = '#FF0000'; + this.lifeBar.style.backgroundColor = '#FF0000'; + + break; + default: + break; + } + + + + + + this.lifeBarContainer.appendChild(this.lifeBar); + this.wGame.document.getElementById('AlignementBars').appendChild(this.lifeBarContainer); + + this.lifeBarContainer.style.left = (pos.x - this.lifeBarContainer.offsetWidth / 2) + 'px'; + this.lifeBarContainer.style.top = (pos.y) + 'px'; + this.lifeBarContainer.style.opacity = ''; + } + + public update(){ + // this.wGame.document.getElementById('fighterLifeBarContainer' + this.fighter.data.playerId).style. + let fighters = this.wGame.actorManager.getPlayers(); + let TheFighter; + for (let index = 0; index < fighters.length; index++) { + if(fighters[index].data.playerId == this.fighter.data.playerId) + TheFighter = fighters[index]; + + } + + if(TheFighter == null) + return true; + if (!this.lifeBar || !this.lifeBarContainer ) { + this.createBar(); + } + + let life = 1; + this.lifeBar.style.width = Math.round(life *100) + '%'; + this.lifeBar.style.right = ''; + + let invisible = false; + + let cellId = TheFighter.cellId; + + if (cellId) { + try { + let scenePos = this.wGame.isoEngine.mapRenderer.getCellSceneCoordinate(cellId); + let pos = this.wGame.isoEngine.mapScene.convertSceneToCanvasCoordinate(scenePos.x, scenePos.y); + this.lifeBarContainer.style.left = (pos.x - this.lifeBarContainer.offsetWidth / 2) + 'px'; + this.lifeBarContainer.style.top = (pos.y) + 'px'; + this.lifeBarContainer.style.opacity = ''; + } + catch(e) { + Logger.info(cellId); + Logger.error(e); + } + } + + } + + public destroy(){ + this.lifeBar.parentElement.removeChild(this.lifeBar); + this.lifeBarContainer.parentElement.removeChild(this.lifeBarContainer); + } +} diff --git a/src/app/core/mods/aligement/alignementUIContainer.ts b/src/app/core/mods/aligement/alignementUIContainer.ts new file mode 100644 index 00000000..3c23b1e5 --- /dev/null +++ b/src/app/core/mods/aligement/alignementUIContainer.ts @@ -0,0 +1,108 @@ +import { alignementUIBar } from "./alignementUIBar"; +import { Logger } from "app/core/electron/logger.helper"; +export class alignementUIContainer { + + private wGame: any | Window; + private container: HTMLDivElement; + private displayed: boolean = false; + private enabled: boolean = true; + private showLifePoints: boolean = true; + private isInFight = false; + private updateInterval: any; + private bars: { [fighterId: number]: alignementUIBar; } = { }; + + constructor(wGame: Window | any) { + this.wGame = wGame; + + this.container = document.createElement('div'); + this.container.id = 'AlignementBars'; + this.container.className = 'AlignementBarsContainer'; + + this.wGame.foreground.rootElement.appendChild(this.container); + + if (this.wGame.gui.fightManager.isInBattle()) this.fightStarted(); + + } + + public toggle() { + if (!this.enabled) { + Logger.info('Show health bar'); + this.enabled = true; + this.showLifePoints = true; + } + else { + Logger.info('Hide health bar'); + if (this.showLifePoints) this.showLifePoints = false; + else this.enabled = false; + } + if (this.isInFight) { + if (this.enabled) this.show(); + else this.hide(); + } + } + + public show() { + if (!this.displayed) { + this.displayed = true; + this.container.style.visibility = 'visible'; + + let player = this.wGame.actorManager.getPlayers(); + for (let index in player) { + let theplayer = player[index]; + this.bars[theplayer.data.playerId] = new alignementUIBar(theplayer, this, this.wGame); + } + this.updateInterval = setInterval(()=>{ + this.update(); + }, 400); + } + } + + public hide() { + if (this.displayed) { + this.displayed = false; + this.container.style.visibility = ''; + for (let fighterId in this.bars) { + this.destroyBar(fighterId); + } + this.bars = []; + this.wGame.document.getElementById('AlignementBars').innerHTML = ''; + clearInterval(this.updateInterval); + } + } + + private update() { + for (let index = 0; index < Object.keys(this.bars).length; index++) { + if(this.bars[Object.keys(this.bars)[index]].update()) + this.destroyBar(Object.keys(this.bars)[index]); + } + + } + + public destroyBar(fighterId: any) { + if (this.bars[fighterId]) { + this.bars[fighterId].destroy(); + delete this.bars[fighterId]; + } + } + + + public fightStarted() { + this.isInFight = true; + if (this.enabled) this.show(); + } + + public fightEnded() { + this.isInFight = false; + if (this.enabled) this.hide(); + } + + public getShowLifePoints(): any { + return this.showLifePoints; + } + + + public destroy() { + this.hide(); + if (this.container && this.container.parentElement) this.container.parentElement.removeChild(this.container); + } +} diff --git a/src/app/core/mods/aligement/temp b/src/app/core/mods/aligement/temp new file mode 100644 index 00000000..6d104bc5 --- /dev/null +++ b/src/app/core/mods/aligement/temp @@ -0,0 +1,58 @@ +this.wGame.actorManager.getPlayers() + +let healthbarCss = document.createElement('style'); + healthbarCss.id = 'healthbarCss'; + healthbarCss.innerHTML = ` + .lifeBarsContainer { + position: absolute; + top: 0; + left: 0; + pointer-events: none; + z-index: 1; + visibility: hidden; + } + + .lifeBarContainer { + box-sizing: border-box; + border: 1px gray solid; + background-color: #222; + height: 6px; + width: 80px; + position: absolute; + border-radius: 3px; + overflow: hidden; + transition-duration: 500ms; + margin-top: 10px; + } + + .lifeBar { + transition-duration: 300ms; + height: 100%; + width: 0%; + background-color: #333; + } + + .shieldBar { + transition-duration: 300ms; + height: 100%; + width: 0%; + margin-left: 50%; + background-color: #944ae0; + position: absolute; + top: 0; + } + + .lifePointsText { + font-size: 12px; + position: absolute; + width: 80px; + color: white; + text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.9); + transition-duration: 500ms; + margin-top: 16px; + margin-left: 2px; + }`; + this.wGame.document.getElementsByTagName('head')[0].appendChild(healthbarCss); + + +(5) [n, n, n, n, n]0: nactorId: 572683actorManager: nactors: ObjectcustomAnimMethods: ObjectfighterIndicator: nullfollowers: Array(8)isCreatureModeOn: falseisTransparentModeOn: falseisoEngine: noccupiedCells: Objectpaused: falsescene: auserActor: nuserId: 898962_fullNicknameLabelCount: 0_nickNamesOn: false_onIdAdded: Object_queuedToCarryActors: Object__proto__: ObjectanimManager: oanimSymbol: Objectanimated: falsebbox: Array(4)canMoveDiagonally: truecarriedActor: nullcarriedEntity: nullcellId: 147circleGraphic: nulldata: ObjectaccountId: 24933835actorId: 572683alignmentInfos: ObjecthumanoidInfo: Objectname: "Zoorkel-shina"playerId: 572683type: "GameRolePlayCharacterInformations"__proto__: Objectdirection: 1displayList: ifighterIndicator: nullfollowers: Array(0)groupBoss: nullicons: Objectid: undefinedisDead: falseisDisplayed: trueisFollower: falseisInvisible: falseisLocked: falseisOutdated: falseisRiding: falseisWhiteListed: falseisolationCoefficient: 0look: Objectmoving: falsenicknameLabel: nullparentActor: nullpath: Array(0)pathTween: srealLook: Objectrenderer: nriderEntity: nullscene: ashowSubentities: truespeedAdjust: 5tint: Array(4)tints: nullupdateList: Array(1)_alpha: 1_cleared: false_highlight: i_hue: Array(4)_layer: 0_position: 147_questIconLoadingStartTime: null_rotation: 0_scaleX: 1_scaleY: 1_spriteRef: n_step: 0_turnNumberLabel: null_x: 602_y: 215alpha: (...)highlight: (...)hue: (...)layer: (...)position: (...)rotation: (...)scaleX: (...)scaleY: (...)step: (...)x: (...)y: (...)__proto__: n1: n2: n3: n4: nactorId: 3466331actorManager: nactors: ObjectcustomAnimMethods: ObjectfighterIndicator: nullfollowers: Array(8)isCreatureModeOn: falseisTransparentModeOn: falseisoEngine: noccupiedCells: Objectpaused: falsescene: auserActor: nuserId: 898962_fullNicknameLabelCount: 0_nickNamesOn: false_onIdAdded: Object_queuedToCarryActors: Object__proto__: ObjectanimManager: oanimationId: "639/motion#AnimStatique_1#1.2#ffffff1c80c802201a83affffffffffff#"animationModifiers: ObjectanimationName: "AnimStatique_1"audioVol: 1bonesId: "639"frameData: nhasSubentities: trueisFx: undefinedloadedAnimations: Objectmirrored: falsenbFrames: 1only4Directions: falsescaleX: 1.2scaleY: 1.2sprite: nsubentities: Array(1)subentityRefs: Objecttemplate: ntints: Array(6)tintsString: "#ffffff1c80c802201a83affffffffffff"tween: s_cleared: false_frame: 0_prevFrame: 0frame: (...)__proto__: ianimSymbol: Objectbase: "AnimStatique"direction: 1id: "AnimStatique_1"__proto__: Objectanimated: falsebbox: Array(4)0: 392.371242341: 480.579777280000032: 544.83: 658.92258length: 4__proto__: Array(0)canMoveDiagonally: truecarriedActor: nullcarriedEntity: nullcellId: 425circleGraphic: nulldata: ObjectaccountId: 138172956actorId: 3466331alignmentInfos: ObjectalignmentGrade: 0alignmentSide: 0alignmentValue: 0characterPower: 3466452_type: "ActorAlignmentInformations"__proto__: ObjecthumanoidInfo: Objectname: "Hescook"playerId: 3466331type: "GameRolePlayCharacterInformations"__proto__: Objectdirection: 1displayList: ifighterIndicator: nullfollowers: Array(0)groupBoss: nullicons: Objectid: undefinedisDead: falseisDisplayed: trueisFollower: falseisInvisible: falseisLocked: falseisOutdated: falseisRiding: trueisWhiteListed: falseisolationCoefficient: 0look: Objectmoving: falsenicknameLabel: nullparentActor: nullpath: Array(0)pathTween: srealLook: Objectrenderer: nriderEntity: oscene: ashowSubentities: truespeedAdjust: 5tint: Array(4)tints: nullupdateList: Array(1)_alpha: 1_cleared: false_highlight: i_hue: Array(4)_layer: 0_position: 425_questIconLoadingStartTime: null_rotation: 0_scaleX: 1_scaleY: 1_spriteRef: n_step: 0_turnNumberLabel: null_x: 430_y: 645alpha: (...)highlight: (...)hue: (...)layer: (...)position: (...)rotation: (...)scaleX: (...)scaleY: (...)step: (...)x: (...)y: (...)__proto__: nlength: 5__proto__: Array(0) \ No newline at end of file diff --git a/src/app/core/mods/aligement/temp2.js b/src/app/core/mods/aligement/temp2.js new file mode 100644 index 00000000..546d5273 --- /dev/null +++ b/src/app/core/mods/aligement/temp2.js @@ -0,0 +1,8 @@ +jQuery(".labico-plus-square-o").on("click",function(){ + setTimeout(function(){ + console.log("trigger"); + jQuery("#edit-value-hours").parent().find(".bootstrap-touchspin-up").find("i").trigger("mousedown");setTimeout(function(){jQuery("#edit-value-minutes").parent().find(".bootstrap-touchspin-up").find("i").trigger("mousedown");},500);setTimeout(function(){ jQuery("#edit-projects").multiselect("select","33"); jQuery("#edit-projects").trigger("change") ;setTimeout(function(){ jQuery("#edit-idtaskcategory").multiselect("select","27"); jQuery("#edit-idtaskcategory").trigger("change"); },2000);},1000); + + },500); + }) + \ No newline at end of file diff --git a/src/app/core/mods/shortcuts/shortcuts.ts b/src/app/core/mods/shortcuts/shortcuts.ts index 8d02b7c9..f5894d46 100644 --- a/src/app/core/mods/shortcuts/shortcuts.ts +++ b/src/app/core/mods/shortcuts/shortcuts.ts @@ -5,13 +5,14 @@ import { ShortcutsHelper } from "app/core/helpers/shortcuts.helper"; import { Option } from "app/core/service/settings.service"; import { Logger } from "app/core/electron/logger.helper"; import { Mover } from "app/core/mods/mover/mover"; +import { Alignement } from '../aligement/alignement'; export class Shortcuts extends Mods { private params: Option.Shortcuts; private shortcutsHelper: ShortcutsHelper; private mover: Mover; - + private alignement : Alignement constructor(wGame: any, params: Option.Shortcuts) { super(wGame); this.params = params; @@ -21,6 +22,7 @@ export class Shortcuts extends Mods { Logger.info(' - enable open_menu'); } this.mover = new Mover(this.wGame); + this.alignement = new Alignement(this.wGame); this.bindAll(); } @@ -79,6 +81,11 @@ export class Shortcuts extends Mods { } }); + // Open menu + this.shortcutsHelper.bind(this.params.diver.alignement_scan, () => { + this.alignement.scan(); + }); + // Open menu this.shortcutsHelper.bind(this.params.diver.open_menu, () => { this.wGame.gui.mainControls.buttonBox._childrenList[14].tap() @@ -142,6 +149,7 @@ export class Shortcuts extends Mods { public reset() { super.reset(); if (this.mover) this.mover.reset(); + if (this.alignement) this.alignement.reset(); this.shortcutsHelper.unBindAll(); } } diff --git a/src/app/core/service/settings.service.ts b/src/app/core/service/settings.service.ts index ddbfe120..5ddfbe77 100644 --- a/src/app/core/service/settings.service.ts +++ b/src/app/core/service/settings.service.ts @@ -419,6 +419,7 @@ export module Option { export class Diver { private _end_turn: string; private _open_chat: string; + private _alignement_scan: string; private _active_open_menu: boolean; private _open_menu: string; private _go_up: string; @@ -444,6 +445,15 @@ export module Option { this._open_chat = open_chat; } + set alignement_scan(active_open_menu: string) { + this.settingsProvider.write('option.shortcuts.diver.active_open_menu', active_open_menu); + this._alignement_scan = active_open_menu; + } + + get alignement_scan(): string { + return this._alignement_scan; + } + set active_open_menu(active_open_menu: boolean) { this.settingsProvider.write('option.shortcuts.diver.active_open_menu', active_open_menu); this._active_open_menu = active_open_menu; @@ -501,6 +511,7 @@ export module Option { constructor(private settingsProvider: SettingsProvider) { this.end_turn = this.settingsProvider.read('option.shortcuts.diver.end_turn'); this.open_chat = this.settingsProvider.read('option.shortcuts.diver.open_chat'); + this.alignement_scan = this.settingsProvider.read('option.shortcuts.diver.alignement_scan'); this.active_open_menu = this.settingsProvider.read('option.shortcuts.diver.active_open_menu'); this.open_menu = this.settingsProvider.read('option.shortcuts.diver.open_menu'); this.go_up = this.settingsProvider.read('option.shortcuts.diver.go_up'); diff --git a/src/app/window/shortcuts/other/other.component.html b/src/app/window/shortcuts/other/other.component.html index 14a4c223..8f218495 100644 --- a/src/app/window/shortcuts/other/other.component.html +++ b/src/app/window/shortcuts/other/other.component.html @@ -13,7 +13,10 @@
- + +
+
+
From ee8d3a0bf71d7cc17063e389ab6fb68dcfb450d8 Mon Sep 17 00:00:00 2001 From: tagazox Date: Tue, 8 Oct 2019 14:02:29 +0200 Subject: [PATCH 02/11] Comment and refacto --- src/app/core/mods/aligement/alignement.ts | 2 +- .../core/mods/aligement/alignementUIBar.ts | 185 ++++++++---------- .../mods/aligement/alignementUIContainer.ts | 2 +- src/app/core/mods/aligement/temp | 58 ------ src/app/core/mods/aligement/temp2.js | 8 - 5 files changed, 87 insertions(+), 168 deletions(-) delete mode 100644 src/app/core/mods/aligement/temp delete mode 100644 src/app/core/mods/aligement/temp2.js diff --git a/src/app/core/mods/aligement/alignement.ts b/src/app/core/mods/aligement/alignement.ts index afd026ae..0e0a1086 100644 --- a/src/app/core/mods/aligement/alignement.ts +++ b/src/app/core/mods/aligement/alignement.ts @@ -72,7 +72,7 @@ export class Alignement extends Mods{ this.container.show(); setTimeout(() => { this.container.destroy(); - }, 2000); + }, 20000); } public reset() { super.reset(); diff --git a/src/app/core/mods/aligement/alignementUIBar.ts b/src/app/core/mods/aligement/alignementUIBar.ts index f1285143..cdfb00e6 100644 --- a/src/app/core/mods/aligement/alignementUIBar.ts +++ b/src/app/core/mods/aligement/alignementUIBar.ts @@ -1,131 +1,116 @@ -import { alignementUIContainer } from "./alignementUIContainer"; import { Logger } from "app/core/electron/logger.helper"; export class alignementUIBar { - private fighter: any; + private player: any; //Le joueur qui détiens la barre de couleur en fct de son alignement private wGame: any; - private lifeBarContainer : HTMLDivElement; - private lifeBar : HTMLDivElement; - private container : alignementUIContainer; + private alignementBarContainer: HTMLDivElement; //Parent de la barre + private alignementBar: HTMLDivElement; //La barre en elle-même - constructor(fighter: any, container: alignementUIContainer, wGame: any | Window){ - this.fighter = fighter; + constructor(player: any, wGame: any | Window) { + this.player = player; this.wGame = wGame; - this.container = container; - this.createBar(); - } - public getId(){ - return this.fighter.data.playerId; + public getId() { + return this.player.data.playerId; } - - - private createBar(){ - /* retrieve data */ - let life = 1; - let cellId = this.fighter.cellId; + private createBar() { + /*Récupération des datas*/ + let cellId = this.player.cellId; let scenePos = this.wGame.isoEngine.mapRenderer.getCellSceneCoordinate(cellId); let pos = this.wGame.isoEngine.mapScene.convertSceneToCanvasCoordinate(scenePos.x, scenePos.y); - /* lifeBarContainer */ - this.lifeBarContainer = document.createElement('div'); - this.lifeBarContainer.id = 'fighterAlignementBarContainer' + this.fighter.data.playerId; - this.lifeBarContainer.className = 'AlignementBarContainer'; - - - - - /* lifeBar */ - this.lifeBar = document.createElement('div'); - this.lifeBar.id = 'fighterAlignementBar' +this.fighter.data.playerId; - this.lifeBar.className = 'AlignementBar'; - - let AlignementInfo = this.fighter.data.alignmentInfos; - switch (AlignementInfo.alignmentSide) { - case 0: - this.lifeBarContainer.style.borderColor = '#000'; - this.lifeBarContainer.style.backgroundColor = '#000'; - - this.lifeBar.style.borderColor = '#000'; - this.lifeBar.style.backgroundColor = '#000'; - break; - case 1: - this.lifeBarContainer.style.borderColor = '#0000FF'; - this.lifeBarContainer.style.backgroundColor = '#0000FF'; + /* Création de la barre conteneur */ + this.alignementBarContainer = document.createElement('div'); + this.alignementBarContainer.id = 'fighterAlignementBarContainer' + this.player.data.playerId; + this.alignementBarContainer.className = 'AlignementBarContainer'; - this.lifeBar.style.borderColor = '#0000FF'; - this.lifeBar.style.backgroundColor = '#0000FF'; - break; - case 2: - this.lifeBarContainer.style.borderColor = '#FF0000'; - this.lifeBarContainer.style.backgroundColor = '#FF0000'; + /* Création de la barre en elle même */ + this.alignementBar = document.createElement('div'); + this.alignementBar.id = 'fighterAlignementBar' + this.player.data.playerId; + this.alignementBar.className = 'AlignementBar'; - this.lifeBar.style.borderColor = '#FF0000'; - this.lifeBar.style.backgroundColor = '#FF0000'; + /*Gestion des couleurs en fonction de l'alignement*/ + let AlignementInfo = this.player.data.alignmentInfos; + this.setColorByAlignement(AlignementInfo.alignmentSide); - break; - default: - break; - } + this.alignementBarContainer.appendChild(this.alignementBar);//Ajoute la barre dans le container + this.wGame.document.getElementById('AlignementBars').appendChild(this.alignementBarContainer); // Ajoute le container dans le container principale. + + /*Placement de la barre en fonction de la cellId du joueur*/ + this.alignementBarContainer.style.left = (pos.x - this.alignementBarContainer.offsetWidth / 2) + 'px'; + this.alignementBarContainer.style.top = (pos.y) + 'px'; + this.alignementBarContainer.style.opacity = ''; + } + public update() { + let player = this.wGame.actorManager.getPlayers(); // Récuperation des joueurs + let currentPlayer; + for (let index = 0; index < player.length; index++) //Je recherche mon joueur dans la liste des joueurs afin d'être sur qu'il existe encore. + if (player[index].data.playerId == this.player.data.playerId) + currentPlayer = player[index]; + if (currentPlayer == null) + return true; // return true -> oui il faut supprimer cette barre, le joueurs n'existe plus. + if (!this.alignementBar || !this.alignementBarContainer) { // Si je n'ai pas déja créé la barre, je la créer. + this.createBar(); + } - this.lifeBarContainer.appendChild(this.lifeBar); - this.wGame.document.getElementById('AlignementBars').appendChild(this.lifeBarContainer); + this.alignementBar.style.width = '100%'; // La couleur de la barre prends toute la place. + this.alignementBar.style.right = ''; - this.lifeBarContainer.style.left = (pos.x - this.lifeBarContainer.offsetWidth / 2) + 'px'; - this.lifeBarContainer.style.top = (pos.y) + 'px'; - this.lifeBarContainer.style.opacity = ''; - } + let cellId = currentPlayer.cellId; //Je récupère la cellID - public update(){ - // this.wGame.document.getElementById('fighterLifeBarContainer' + this.fighter.data.playerId).style. - let fighters = this.wGame.actorManager.getPlayers(); - let TheFighter; - for (let index = 0; index < fighters.length; index++) { - if(fighters[index].data.playerId == this.fighter.data.playerId) - TheFighter = fighters[index]; - - } - - if(TheFighter == null) - return true; - if (!this.lifeBar || !this.lifeBarContainer ) { - this.createBar(); + if (cellId) { + try { + let scenePos = this.wGame.isoEngine.mapRenderer.getCellSceneCoordinate(cellId); + let pos = this.wGame.isoEngine.mapScene.convertSceneToCanvasCoordinate(scenePos.x, scenePos.y); + this.alignementBarContainer.style.left = (pos.x - this.alignementBarContainer.offsetWidth / 2) + 'px'; + this.alignementBarContainer.style.top = (pos.y) + 'px'; + this.alignementBarContainer.style.opacity = ''; } - - let life = 1; - this.lifeBar.style.width = Math.round(life *100) + '%'; - this.lifeBar.style.right = ''; - - let invisible = false; - - let cellId = TheFighter.cellId; - - if (cellId) { - try { - let scenePos = this.wGame.isoEngine.mapRenderer.getCellSceneCoordinate(cellId); - let pos = this.wGame.isoEngine.mapScene.convertSceneToCanvasCoordinate(scenePos.x, scenePos.y); - this.lifeBarContainer.style.left = (pos.x - this.lifeBarContainer.offsetWidth / 2) + 'px'; - this.lifeBarContainer.style.top = (pos.y) + 'px'; - this.lifeBarContainer.style.opacity = ''; - } - catch(e) { - Logger.info(cellId); - Logger.error(e); - } + catch (e) { + Logger.info(cellId); + Logger.error(e); } - + } + + } + + public destroy() { // Remove les 2 élément HTML + this.alignementBar.parentElement.removeChild(this.alignementBar); + this.alignementBarContainer.parentElement.removeChild(this.alignementBarContainer); } - public destroy(){ - this.lifeBar.parentElement.removeChild(this.lifeBar); - this.lifeBarContainer.parentElement.removeChild(this.lifeBarContainer); + private setColorByAlignement(alignmentSide :any){ + switch (alignmentSide) { + case 1://Le personnage est bontarien + this.alignementBarContainer.style.borderColor = '#1f8fcb'; + this.alignementBarContainer.style.backgroundColor = '#1f8fcb'; + + this.alignementBar.style.borderColor = '#1f8fcb'; + this.alignementBar.style.backgroundColor = '#1f8fcb'; + break; + case 2://Le personnage est brakmarien + this.alignementBarContainer.style.borderColor = '#820000'; + this.alignementBarContainer.style.backgroundColor = '#820000'; + + this.alignementBar.style.borderColor = '#820000'; + this.alignementBar.style.backgroundColor = '#820000'; + + break; + default: // Le personnage est neutre ou d'un alignement non supporté. + this.alignementBarContainer.style.borderColor = '#000'; + this.alignementBarContainer.style.backgroundColor = '#000'; + + this.alignementBar.style.borderColor = '#000'; + this.alignementBar.style.backgroundColor = '#000'; + break; + } } } diff --git a/src/app/core/mods/aligement/alignementUIContainer.ts b/src/app/core/mods/aligement/alignementUIContainer.ts index 3c23b1e5..6eb8adb0 100644 --- a/src/app/core/mods/aligement/alignementUIContainer.ts +++ b/src/app/core/mods/aligement/alignementUIContainer.ts @@ -49,7 +49,7 @@ export class alignementUIContainer { let player = this.wGame.actorManager.getPlayers(); for (let index in player) { let theplayer = player[index]; - this.bars[theplayer.data.playerId] = new alignementUIBar(theplayer, this, this.wGame); + this.bars[theplayer.data.playerId] = new alignementUIBar(theplayer, this.wGame); } this.updateInterval = setInterval(()=>{ this.update(); diff --git a/src/app/core/mods/aligement/temp b/src/app/core/mods/aligement/temp deleted file mode 100644 index 6d104bc5..00000000 --- a/src/app/core/mods/aligement/temp +++ /dev/null @@ -1,58 +0,0 @@ -this.wGame.actorManager.getPlayers() - -let healthbarCss = document.createElement('style'); - healthbarCss.id = 'healthbarCss'; - healthbarCss.innerHTML = ` - .lifeBarsContainer { - position: absolute; - top: 0; - left: 0; - pointer-events: none; - z-index: 1; - visibility: hidden; - } - - .lifeBarContainer { - box-sizing: border-box; - border: 1px gray solid; - background-color: #222; - height: 6px; - width: 80px; - position: absolute; - border-radius: 3px; - overflow: hidden; - transition-duration: 500ms; - margin-top: 10px; - } - - .lifeBar { - transition-duration: 300ms; - height: 100%; - width: 0%; - background-color: #333; - } - - .shieldBar { - transition-duration: 300ms; - height: 100%; - width: 0%; - margin-left: 50%; - background-color: #944ae0; - position: absolute; - top: 0; - } - - .lifePointsText { - font-size: 12px; - position: absolute; - width: 80px; - color: white; - text-shadow: 0px 0px 5px rgba(0, 0, 0, 0.9); - transition-duration: 500ms; - margin-top: 16px; - margin-left: 2px; - }`; - this.wGame.document.getElementsByTagName('head')[0].appendChild(healthbarCss); - - -(5) [n, n, n, n, n]0: nactorId: 572683actorManager: nactors: ObjectcustomAnimMethods: ObjectfighterIndicator: nullfollowers: Array(8)isCreatureModeOn: falseisTransparentModeOn: falseisoEngine: noccupiedCells: Objectpaused: falsescene: auserActor: nuserId: 898962_fullNicknameLabelCount: 0_nickNamesOn: false_onIdAdded: Object_queuedToCarryActors: Object__proto__: ObjectanimManager: oanimSymbol: Objectanimated: falsebbox: Array(4)canMoveDiagonally: truecarriedActor: nullcarriedEntity: nullcellId: 147circleGraphic: nulldata: ObjectaccountId: 24933835actorId: 572683alignmentInfos: ObjecthumanoidInfo: Objectname: "Zoorkel-shina"playerId: 572683type: "GameRolePlayCharacterInformations"__proto__: Objectdirection: 1displayList: ifighterIndicator: nullfollowers: Array(0)groupBoss: nullicons: Objectid: undefinedisDead: falseisDisplayed: trueisFollower: falseisInvisible: falseisLocked: falseisOutdated: falseisRiding: falseisWhiteListed: falseisolationCoefficient: 0look: Objectmoving: falsenicknameLabel: nullparentActor: nullpath: Array(0)pathTween: srealLook: Objectrenderer: nriderEntity: nullscene: ashowSubentities: truespeedAdjust: 5tint: Array(4)tints: nullupdateList: Array(1)_alpha: 1_cleared: false_highlight: i_hue: Array(4)_layer: 0_position: 147_questIconLoadingStartTime: null_rotation: 0_scaleX: 1_scaleY: 1_spriteRef: n_step: 0_turnNumberLabel: null_x: 602_y: 215alpha: (...)highlight: (...)hue: (...)layer: (...)position: (...)rotation: (...)scaleX: (...)scaleY: (...)step: (...)x: (...)y: (...)__proto__: n1: n2: n3: n4: nactorId: 3466331actorManager: nactors: ObjectcustomAnimMethods: ObjectfighterIndicator: nullfollowers: Array(8)isCreatureModeOn: falseisTransparentModeOn: falseisoEngine: noccupiedCells: Objectpaused: falsescene: auserActor: nuserId: 898962_fullNicknameLabelCount: 0_nickNamesOn: false_onIdAdded: Object_queuedToCarryActors: Object__proto__: ObjectanimManager: oanimationId: "639/motion#AnimStatique_1#1.2#ffffff1c80c802201a83affffffffffff#"animationModifiers: ObjectanimationName: "AnimStatique_1"audioVol: 1bonesId: "639"frameData: nhasSubentities: trueisFx: undefinedloadedAnimations: Objectmirrored: falsenbFrames: 1only4Directions: falsescaleX: 1.2scaleY: 1.2sprite: nsubentities: Array(1)subentityRefs: Objecttemplate: ntints: Array(6)tintsString: "#ffffff1c80c802201a83affffffffffff"tween: s_cleared: false_frame: 0_prevFrame: 0frame: (...)__proto__: ianimSymbol: Objectbase: "AnimStatique"direction: 1id: "AnimStatique_1"__proto__: Objectanimated: falsebbox: Array(4)0: 392.371242341: 480.579777280000032: 544.83: 658.92258length: 4__proto__: Array(0)canMoveDiagonally: truecarriedActor: nullcarriedEntity: nullcellId: 425circleGraphic: nulldata: ObjectaccountId: 138172956actorId: 3466331alignmentInfos: ObjectalignmentGrade: 0alignmentSide: 0alignmentValue: 0characterPower: 3466452_type: "ActorAlignmentInformations"__proto__: ObjecthumanoidInfo: Objectname: "Hescook"playerId: 3466331type: "GameRolePlayCharacterInformations"__proto__: Objectdirection: 1displayList: ifighterIndicator: nullfollowers: Array(0)groupBoss: nullicons: Objectid: undefinedisDead: falseisDisplayed: trueisFollower: falseisInvisible: falseisLocked: falseisOutdated: falseisRiding: trueisWhiteListed: falseisolationCoefficient: 0look: Objectmoving: falsenicknameLabel: nullparentActor: nullpath: Array(0)pathTween: srealLook: Objectrenderer: nriderEntity: oscene: ashowSubentities: truespeedAdjust: 5tint: Array(4)tints: nullupdateList: Array(1)_alpha: 1_cleared: false_highlight: i_hue: Array(4)_layer: 0_position: 425_questIconLoadingStartTime: null_rotation: 0_scaleX: 1_scaleY: 1_spriteRef: n_step: 0_turnNumberLabel: null_x: 430_y: 645alpha: (...)highlight: (...)hue: (...)layer: (...)position: (...)rotation: (...)scaleX: (...)scaleY: (...)step: (...)x: (...)y: (...)__proto__: nlength: 5__proto__: Array(0) \ No newline at end of file diff --git a/src/app/core/mods/aligement/temp2.js b/src/app/core/mods/aligement/temp2.js deleted file mode 100644 index 546d5273..00000000 --- a/src/app/core/mods/aligement/temp2.js +++ /dev/null @@ -1,8 +0,0 @@ -jQuery(".labico-plus-square-o").on("click",function(){ - setTimeout(function(){ - console.log("trigger"); - jQuery("#edit-value-hours").parent().find(".bootstrap-touchspin-up").find("i").trigger("mousedown");setTimeout(function(){jQuery("#edit-value-minutes").parent().find(".bootstrap-touchspin-up").find("i").trigger("mousedown");},500);setTimeout(function(){ jQuery("#edit-projects").multiselect("select","33"); jQuery("#edit-projects").trigger("change") ;setTimeout(function(){ jQuery("#edit-idtaskcategory").multiselect("select","27"); jQuery("#edit-idtaskcategory").trigger("change"); },2000);},1000); - - },500); - }) - \ No newline at end of file From c6b114a76e41cc36e03ce817a2bb3400c7476df8 Mon Sep 17 00:00:00 2001 From: tagazox Date: Fri, 11 Oct 2019 14:28:32 +0200 Subject: [PATCH 03/11] Finition du module de scan des alignements. --- src/app/core/helpers/shortcuts.helper.ts | 9 +++- src/app/core/mods/aligement/alignement.ts | 44 ++++++------------ .../core/mods/aligement/alignementUIBar.ts | 4 +- .../mods/aligement/alignementUIContainer.ts | 45 ------------------- src/app/core/mods/hide-mount/hide-mount.ts | 1 - src/app/core/mods/shortcuts/shortcuts.ts | 8 ++-- 6 files changed, 29 insertions(+), 82 deletions(-) diff --git a/src/app/core/helpers/shortcuts.helper.ts b/src/app/core/helpers/shortcuts.helper.ts index a1ec9e1f..3e39a7e0 100644 --- a/src/app/core/helpers/shortcuts.helper.ts +++ b/src/app/core/helpers/shortcuts.helper.ts @@ -12,7 +12,6 @@ export class ShortcutsHelper { (this.window).key(shortcut, (e: KeyboardEvent) => { action(e); }); - this.shortcuts.push(shortcut); } @@ -24,6 +23,14 @@ export class ShortcutsHelper { this.shortcutsVanilla.push(listener); } + public bindVanillaKeyUp(shortcut: string, action: (e?: KeyboardEvent) => void): void { + let listener = (e: KeyboardEvent) => { + if (shortcut.includes(e.key.toLowerCase()) ) action(e); + }; + (this.window).addEventListener('keyup', listener); + + this.shortcutsVanilla.push(listener); + } public unBindAll(): void{ this.shortcuts.forEach((shortcut) => { diff --git a/src/app/core/mods/aligement/alignement.ts b/src/app/core/mods/aligement/alignement.ts index 0e0a1086..8c26fe58 100644 --- a/src/app/core/mods/aligement/alignement.ts +++ b/src/app/core/mods/aligement/alignement.ts @@ -7,32 +7,14 @@ import { alignementUIContainer } from "./alignementUIContainer"; */ export class Alignement extends Mods{ - private AlignementBarContainer : HTMLDivElement; - private AlignementBar : HTMLDivElement; - private shieldBar : HTMLDivElement; - private lifePointsText : HTMLDivElement; private container : alignementUIContainer; constructor (wGame: any | Window) { super(wGame); - - //Side definition : - // 0 => neutre - // 1 => Bonta - // 2 => Brakmar - // - //Grade : - //0 = aussi les ailes cachés. - // de 0 à 10 - //Value Currently unknown - - - - - - let healthbarCss = document.createElement('style'); - healthbarCss.id = 'AlignementBarCss'; - healthbarCss.innerHTML = ` + /*Ajout de la balyse