Files
source/Laptop/IMP Text System.h
T
fd2c74727e Make LANGUAGE switchable in runtime (#653)
squashed into a single commit because doing it in steps that all
compiled involved a lot of boilerplate that is pointless to commit to
the repository. GH still has the PR for reference.

g_lang, MAX_MESSAGES_ON_MAP_BOTTOM, and GetLanguagePrefix() were
compile-time constants selected by the ENGLISH/GERMAN/... build
define. They're now runtime, defaulting to the same per-exe value the
define used to pick, and overridable at startup from [Ja2 Settings]
LANGUAGE in Ja2.ini.

-

XMLTacticalMessages is filled at runtime from NewTacticalMessages.xml,
never from compiled-in per-language data: all 8 per-language definitions
were the identical all-zero { L"" }. Delete them and define one shared
buffer in Utils/XML_Language.cpp (the loader) instead of pointer-rebinding
it like the static tables — this drops 9 dead 800KB zero-buffers (8
namespaced copies in LanguageStrings.cpp plus the standalone one) and
leaves no bind-ordering hazard for the XML load path.

-

ExportStrings.cpp privately recompiled one language's full text table
by #including the raw _<LANG>Text.cpp inside namespace Loc, keyed off
the exe-level ENGLISH/GERMAN/... compile macro (whichever the build
happened to select). That's redundant with the pointer globals every
other subsystem already uses (Text.h / LanguageStrings.cpp).

Drop the private copy; the unqualified table names in Loc::ExportStrings
now resolve to the global pointer externs, which BindLanguageStrings has
already rebound to the runtime g_lang by the time this runs (EXPORT_STRINGS
ini flag, checked after GetRuntimeSettings in sgp.cpp). gs_Lang (used only
by Loc::Translate for the Polish/Russian byte remap on raw .edt exports) is
now derived from g_lang via ToLocLanguage, so the export always matches
whatever language is actually active instead of a compile-time pick.

-

Editor/popupmenu.cpp and Strategic/Scheduling.cpp kept their own
call-site extern of gszScheduleActions as CHAR16[NUM_SCHEDULE_ACTIONS][20]
after the real definition changed into a rebindable pointer
(CHAR16 (*)[20], LanguageStrings.cpp). MSVC decays the outer array
dimension when mangling globals, so both declarations produce the same
symbol (?gszScheduleActions@@3PAY0BE@_WA) and the mismatch linked
silently -- but the array-typed TUs then indexed the 4-byte pointer
slot itself as string data, so the editor schedule popup and the map
schedule message text read garbage.

-

add text.def to be single-source of truth on symbol names and use it
 .much simpler, less error prone if adding more strings

-

add pseudo interface for language state. MAX_SAGES_ON_BOTTOM must always
 change in lockstep with g_lang. this isn't foolproof but better

---------

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-07-21 05:33:03 -03:00

149 lines
2.4 KiB
C

#ifndef __IMP_TEXT_SYSTEM_H
#define __IMP_TEXT_SYSTEM_H
void LoadAndDisplayIMPText( INT16 sStartX, INT16 sStartY, INT16 sLineLength, INT16 sIMPTextRecordNumber, UINT32 uiFont, UINT8 ubColor, BOOLEAN fShadow, UINT32 uiFlags);
void InitializeImpRecordLengthList( void );
void PrintImpText( void );
void PrintIMPPersonalityQuizQuestionAndAnsers( void );
// buttons text
extern STR16* pImpButtonText;
// extra strings not found in IMP Text Document
extern STR16* pExtraIMPStrings;
extern STR16* pSkillTraitBeginIMPStrings; // added - SANDRO
enum{
IMP_HOME_1,
IMP_HOME_2,
IMP_HOME_3,
IMP_HOME_4,
IMP_HOME_5,
IMP_HOME_6,
IMP_HOME_7,
IMP_HOME_8,
IMP_HOME_9,
IMP_HOME_10,
IMP_ABOUT_US_1,
IMP_ABOUT_US_2,
IMP_ABOUT_US_3,
IMP_ABOUT_US_4,
IMP_ABOUT_US_5,
IMP_ABOUT_US_6,
IMP_ABOUT_US_7,
IMP_ABOUT_US_8,
IMP_ABOUT_US_9,
IMP_ABOUT_US_10,
IMP_ABOUT_US_11,
IMP_ABOUT_US_12,
IMP_MAIN_1,
IMP_MAIN_2,
IMP_MAIN_3,
IMP_MAIN_4,
IMP_MAIN_5,
IMP_MAIN_6,
IMP_MAIN_7,
IMP_MAIN_8,
IMP_MAIN_9,
IMP_BEGIN_1,
IMP_BEGIN_2,
IMP_BEGIN_3,
IMP_BEGIN_4,
IMP_BEGIN_5,
IMP_BEGIN_6,
IMP_BEGIN_7,
IMP_BEGIN_8,
IMP_B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