Skip to content

Commit

Permalink
Add the name of culture and namesbase in the name editor dialog (#1033)
Browse files Browse the repository at this point in the history
* Add the name of culture and namesbase in the name editor dialog

Added the name of the culture and  namesbase in the dialog "name editor".
This tells information on the "click to generate a culture-specific name"
It tells you the culture before changing name.

* cultureName into cultureId + cultureName

And deleted the incomplete code of showing culture name on datatip

* refactor: leave culture name only

---------

Co-authored-by: Azgaar <[email protected]>
  • Loading branch information
Avengium and Azgaar authored Feb 14, 2024
1 parent bc88ad4 commit 963dafb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 9 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4700,7 +4700,7 @@
<span data-tip="Speak the name. You can change voice and language in options" class="speaker">🔊</span>
<span
id="provinceNameEditorShortCulture"
data-tip="Generate culture-specific name"
data-tip="Generate culture-specific name for the province"
class="icon-book pointer"
></span>
<span id="provinceNameEditorShortRandom" data-tip="Generate random name" class="icon-globe pointer"></span>
Expand Down Expand Up @@ -4776,6 +4776,14 @@
class="icon-arrows-cw pointer"
></span>
</div>

<div
id="provinceCultureName"
data-tip="Dominant culture in the province. This defines culture-based naming. Can be changed via the Cultures Editor"
style="margin-top: 0.2em"
>
Dominant culture:&nbsp;<span id="provinceCultureDisplay"></span>
</div>
</div>

<div id="namesbaseEditor" class="dialog stable textual" style="display: none">
Expand Down
4 changes: 2 additions & 2 deletions modules/dynamic/editors/states-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,13 @@ function editStateName(state) {
modules.editStateName = true;

// add listeners
byId("stateNameEditorShortCulture").on("click", regenerateShortNameCuture);
byId("stateNameEditorShortCulture").on("click", regenerateShortNameCulture);
byId("stateNameEditorShortRandom").on("click", regenerateShortNameRandom);
byId("stateNameEditorAddForm").on("click", addCustomForm);
byId("stateNameEditorCustomForm").on("change", addCustomForm);
byId("stateNameEditorFullRegenerate").on("click", regenerateFullName);

function regenerateShortNameCuture() {
function regenerateShortNameCulture() {
const state = +stateNameEditor.dataset.state;
const culture = pack.states[state].culture;
const name = Names.getState(Names.getCultureShort(culture), culture);
Expand Down
9 changes: 6 additions & 3 deletions modules/ui/provinces-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function editProvinces() {
// move all burgs to a new state
province.burgs.forEach(b => (burgs[b].state = newStateId));

// difine new state attributes
// define new state attributes
const {cell: center, culture} = burgs[burgId];
const color = getRandomColor();
const coa = province.coa;
Expand Down Expand Up @@ -501,6 +501,9 @@ function editProvinces() {
applyOption(provinceNameEditorSelectForm, p.formName);
document.getElementById("provinceNameEditorFull").value = p.fullName;

const cultureId = pack.cells.culture[p.center];
document.getElementById("provinceCultureDisplay").innerText = pack.cultures[cultureId].name;

$("#provinceNameEditor").dialog({
resizable: false,
title: "Change province name",
Expand All @@ -520,12 +523,12 @@ function editProvinces() {
modules.editProvinceName = true;

// add listeners
document.getElementById("provinceNameEditorShortCulture").addEventListener("click", regenerateShortNameCuture);
document.getElementById("provinceNameEditorShortCulture").addEventListener("click", regenerateShortNameCulture);
document.getElementById("provinceNameEditorShortRandom").addEventListener("click", regenerateShortNameRandom);
document.getElementById("provinceNameEditorAddForm").addEventListener("click", addCustomForm);
document.getElementById("provinceNameEditorFullRegenerate").addEventListener("click", regenerateFullName);

function regenerateShortNameCuture() {
function regenerateShortNameCulture() {
const province = +provinceNameEditor.dataset.province;
const culture = pack.cells.culture[pack.provinces[province].center];
const name = Names.getState(Names.getCultureShort(culture), culture);
Expand Down

0 comments on commit 963dafb

Please sign in to comment.