Skip to content

Commit

Permalink
fix: logChoices was not being used
Browse files Browse the repository at this point in the history
  • Loading branch information
lunafromthemoon committed Feb 15, 2022
1 parent 561fbd5 commit d5c541f
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 7 deletions.
Binary file added dev-only/assets/gui/en/langbtn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added dev-only/assets/gui/es/langbtn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dev-only/i18n.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title> RenJS </title>
<script type="text/javascript" src="renjs.js"></script>
<script src="story/i18n/boot.js"></script>
<script src="plugins/ChangeLang.js"></script>
</head>
<body style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px;margin-right: 0px;">
</body>
Expand Down
12 changes: 12 additions & 0 deletions dev-only/plugins/ChangeLang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class ChangeLang extends RenJS.Plugin {

onInit(params) {
this.game.gui.bindingActions['changeLang'] = async ()=>{
// remove saved lang setting and reload page
localStorage.removeItem('RenJS_I18N' + this.game.config.name);
location.reload();
}
}
}

RenJSGame.addPlugin('ChangeLang',ChangeLang)
1 change: 1 addition & 0 deletions dev-only/story/i18n/en/Accessibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
buttons:
openMenu saveload: save/load
openMenu settings: settings
changeLang: change language
# Replacements for accessible slider labels
# the default labels will be the internal binding + user preference keys
sliders:
Expand Down
14 changes: 14 additions & 0 deletions dev-only/story/i18n/en/GUI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ config:
'y': 506
x: 616
assetType: spritesheets
- id: langbtn
sfx: none
slot: '0'
binding: changeLang
height: '82'
width: '313'
'y': 506
x: 266
assetType: spritesheets
sliders:
- id: asset12
binding: bgmv
Expand Down Expand Up @@ -388,6 +397,11 @@ assets:
fileName: saveloadasset17.png
w: 163
h: 82
langbtn:
name: langbtn
fileName: en/langbtn.png
w: 313
h: 82
asset21:
name: asset21
fileName: hudasset21.png
Expand Down
1 change: 1 addition & 0 deletions dev-only/story/i18n/es/Accessibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ buttons:
start: iniciar
return: volver
skip: saltarse
changeLang: cambiar idioma
save 0: guardar 0
save 1: guardar 1
save 2: guardar 2
Expand Down
14 changes: 14 additions & 0 deletions dev-only/story/i18n/es/GUI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ config:
'y': '506'
x: '616'
assetType: spritesheets
- id: langbtn
sfx: none
slot: '0'
binding: changeLang
height: '82'
width: '313'
'y': 506
x: 266
assetType: spritesheets
sliders:
- id: asset12
binding: bgmv
Expand Down Expand Up @@ -443,6 +452,11 @@ assets:
fileName: es/saveloadasset53.png
w: 145
h: 52
langbtn:
name: langbtn
fileName: es/langbtn.png
w: 313
h: 82
fonts:
fontsaudimat-mono:
fileName: fontsfontsaudimat-mono.ttf
Expand Down
Binary file added docs/examples/assets/gui/en/langbtn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/examples/assets/gui/es/langbtn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/examples/i18n.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,5 +267,6 @@ <h4 class="accordion-item__label"></h4>
<script type="text/javascript" src="../assets/js/tabs.js"></script>
<script src="/downloads/releases/renjs.js"></script>
<script src="i18n/boot.js"></script>
<script src="i18n/ChangeLang.js"></script>

</html>
12 changes: 12 additions & 0 deletions docs/examples/i18n/ChangeLang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class ChangeLang extends RenJS.Plugin {

onInit(params) {
this.game.gui.bindingActions['changeLang'] = async ()=>{
// remove saved lang setting and reload page
localStorage.removeItem('RenJS_I18N' + this.game.config.name);
location.reload();
}
}
}

RenJSGame.addPlugin('ChangeLang',ChangeLang)
14 changes: 14 additions & 0 deletions docs/examples/i18n/en/GUI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ config:
'y': 506
x: 616
assetType: spritesheets
- id: langbtn
sfx: none
slot: '0'
binding: changeLang
height: '82'
width: '313'
'y': 506
x: 266
assetType: spritesheets
sliders:
- id: asset12
binding: bgmv
Expand Down Expand Up @@ -388,6 +397,11 @@ assets:
fileName: saveloadasset17.png
w: 163
h: 82
langbtn:
name: langbtn
fileName: en/langbtn.png
w: 313
h: 82
asset21:
name: asset21
fileName: hudasset21.png
Expand Down
18 changes: 16 additions & 2 deletions docs/examples/i18n/es/GUI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ config:
'y': '506'
x: '616'
assetType: spritesheets
- id: langbtn
sfx: none
slot: '0'
binding: changeLang
height: '82'
width: '313'
'y': 506
x: 266
assetType: spritesheets
sliders:
- id: asset12
binding: bgmv
Expand Down Expand Up @@ -133,8 +142,8 @@ config:
message-box:
id: asset19
text-width: '540'
offset-y: '24'
offset-x: '24'
offset-y: '16'
offset-x: '16'
align: left
color: '#89BAA8'
font: fontsaudimat-mono
Expand Down Expand Up @@ -443,6 +452,11 @@ assets:
fileName: es/saveloadasset53.png
w: 145
h: 52
langbtn:
name: langbtn
fileName: es/langbtn.png
w: 313
h: 82
fonts:
fontsaudimat-mono:
fileName: fontsfontsaudimat-mono.ttf
Expand Down
4 changes: 2 additions & 2 deletions src/gui/RJSHUD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ export default class RJSHUD extends RJSMenu {
visualChoice.anchor.set(0.5);
visualChoice.updateTransform();
this.visualChoices.addChild(visualChoice);
if (choice.previouslyChosen){
visualChoice.tint = Color.hexToRGB(defaultChoicesConfig.chosenColor);
if (this.game.storyConfig.logChoices && defaultChoicesConfig.chosenColor && choice.previouslyChosen){
visualChoice.tint = Color.hexToColor(this.config.chosenColor).color;
}
return visualChoice;
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/elements/ChoiceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ export default class ChoiceHandler extends Graphics {
text.setText(setTextStyles(choice.choiceText,text), true);
chBox.addChild(text);

if (choice.previouslyChosen){
chBox.tint = Color.hexToRGB(this.config.chosenColor);
if (this.game.storyConfig.logChoices && this.config.chosenColor && choice.previouslyChosen){
chBox.tint = Color.hexToColor(this.config.chosenColor).color;
}
return chBox;
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/elements/NameBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class NameBox extends Sprite {
this.text.setText(text, true);
this.text.updateTransform();
if (this.config.tintStyle === 'box'){
this.tint = Color.hexToRGB(color);
this.tint = Color.hexToColor(color).color;
} else {
// change name color
this.text.fill = color;
Expand Down

0 comments on commit d5c541f

Please sign in to comment.