Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
secsome committed Jan 12, 2023
2 parents 2a323ae + 0a3a2ba commit 3b2451b
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 75 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# FINALALERT2 - SP CHANGELOG

## RELEASE 1.5.1 (2023-01-12)
- Fixed the bug that Preview was incorrectly saved in version 1.5.0
- Built-in script params can be translated
- Trigger repeat type can be translated

## RELEASE 1.5.0 (2023-01-03)
- Implement Auto Property Brush
- New ***ExtConfig*** : `DDrawInVideoMem` = **BOOLEAN**, defaults to true
Expand Down
9 changes: 9 additions & 0 deletions DOCUMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,15 @@ NOTICE THAT UNDOREDO AND COPYPASTE HASN'T BEEN SUPPORTED YET!~~
AllieEditorOK = TEXT
AllieEditorCancel = TEXT
TileManagerTitle = TEXT
; Script params
; For example, ScriptParam.Status.0
ScriptParam.Target.[0 - 11, except 8] = TEXT
ScriptParam.SplitGroup.[0 - 3] = TEXT
ScriptParam.Facing.[0 - 7] = TEXT
ScriptParam.TalkBubble.[0 - 3] = TEXT
ScriptParam.Status.[0 - 31] = TEXT
ScriptParam.Boolean.[0 - 1] = TEXT
ScriptExtraParam.Preference.[0 - 3] = TEXT
```
## WRITE IN THE END
Expand Down
2 changes: 1 addition & 1 deletion FA2pp
Submodule FA2pp updated 1 files
+12 −0 CMapData.h
10 changes: 7 additions & 3 deletions FA2sp/Ext/CMapData/Body.Pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,19 @@ void CMapDataExt::PackExt(bool UpdatePreview, bool Description)

if (UpdatePreview)
{
Logger::Raw("Removing old previewpack\n");
INI.DeleteSection("PreviewPack");
INI.DeleteSection("Preview");

Logger::Raw("Packing previewpack\n");

BITMAPINFO info; void* buffer; int stride;
BITMAPINFO info; unsigned char* buffer; int stride;
GetMapPreview(buffer, &info, stride);

const int width = info.bmiHeader.biWidth;
const int height = info.bmiHeader.biHeight;
auto rawdata = new unsigned char[3 * width * height];
const unsigned char* p = (const unsigned char*)buffer;
auto p = buffer;
for (int x = 0; x < width; ++x)
{
for (int y = 0; y < height; ++y)
Expand All @@ -85,7 +89,7 @@ void CMapDataExt::PackExt(bool UpdatePreview, bool Description)

ppmfc::CString size;
size.Format("0,0,%d,%d", width, height);
INI.WriteString("PreviewPack", "Size", size);
INI.WriteString("Preview", "Size", size);
Logger::Raw(" done\n");
}
}
Expand Down
10 changes: 6 additions & 4 deletions FA2sp/Ext/CScriptTypes/Body.CurrentScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <CINI.h>
#include <CFinalSunDlg.h>

#include "../../Helpers/Translations.h"

CurrentScript* CScriptTypesExt::ExtCurrentScript;
ppmfc::CString CurrentScript::ToString()
{
Expand Down Expand Up @@ -194,10 +196,10 @@ void CurrentScript::LoadExtraParamBox(ppmfc::CComboBox& comboBox, int actionInde

if (actionIndex == 46 || actionIndex == 47 || actionIndex == 56 || actionIndex == 58)
{
comboBox.SetItemData(comboBox.AddString("0 - Min Threat"), 0);
comboBox.SetItemData(comboBox.AddString("1 - Max Threat"), 1);
comboBox.SetItemData(comboBox.AddString("2 - Nearest"), 2);
comboBox.SetItemData(comboBox.AddString("3 - Farthest"), 3);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptExtraParam.Preference.0", "0 - Min Threat")), 0);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptExtraParam.Preference.1", "1 - Max Threat")), 1);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptExtraParam.Preference.2", "2 - Nearest")), 2);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptExtraParam.Preference.3", "3 - Farthest")), 3);
return;
}

Expand Down
123 changes: 62 additions & 61 deletions FA2sp/Ext/CScriptTypes/Functional.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../../Helpers/STDHelpers.h"
#include "../../Helpers/ControlHelpers.h"
#include "../../FA2sp.h"
#include "../../Helpers/Translations.h"

class CScriptTypesFunctions
{
Expand Down Expand Up @@ -117,17 +118,17 @@ static void CScriptTypes_LoadParams_Target(ppmfc::CComboBox& comboBox)
{
comboBox.DeleteAllStrings();

comboBox.SetItemData(comboBox.AddString("0 - Not specified"), 0);
comboBox.SetItemData(comboBox.AddString("1 - Anything (uses auto-targeting)"), 1);
comboBox.SetItemData(comboBox.AddString("2 - Buildings"), 2);
comboBox.SetItemData(comboBox.AddString("3 - Harvesters"), 3);
comboBox.SetItemData(comboBox.AddString("4 - Infantry"), 4);
comboBox.SetItemData(comboBox.AddString("5 - Vehicles"), 5);
comboBox.SetItemData(comboBox.AddString("6 - Factories"), 6);
comboBox.SetItemData(comboBox.AddString("7 - Base defenses"), 7);
comboBox.SetItemData(comboBox.AddString("9 - Power plants"), 9);
comboBox.SetItemData(comboBox.AddString("10 - Occupiables"), 10);
comboBox.SetItemData(comboBox.AddString("11 - Tech Buildings"), 11);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.0", "0 - Not specified")), 0);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.1", "1 - Anything (uses auto-targeting)")), 1);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.2", "2 - Buildings")), 2);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.3", "3 - Harvesters")), 3);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.4", "4 - Infantry")), 4);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.5", "5 - Vehicles")), 5);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.6", "6 - Factories")), 6);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.7", "7 - Base defenses")), 7);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.9", "9 - Power plants")), 9);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.10", "10 - Occupiables")), 10);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Target.11", "11 - Tech Buildings")), 11);
}

// 2
Expand Down Expand Up @@ -220,10 +221,10 @@ static void CScriptTypes_LoadParams_SplitGroup(ppmfc::CComboBox& comboBox)
{
comboBox.DeleteAllStrings();

comboBox.SetItemData(comboBox.AddString("0 - Keep Transports, Keep Units"), 0);
comboBox.SetItemData(comboBox.AddString("1 - Keep Transports, Lose Units"), 1);
comboBox.SetItemData(comboBox.AddString("2 - Lose Transports, Keep Units"), 2);
comboBox.SetItemData(comboBox.AddString("3 - Lose Transports, Lose Units"), 3);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.SplitGroup.0", "0 - Keep Transports, Keep Units")), 0);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.SplitGroup.1", "1 - Keep Transports, Lose Units")), 1);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.SplitGroup.2", "2 - Lose Transports, Keep Units")), 2);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.SplitGroup.3", "3 - Lose Transports, Lose Units")), 3);
}

// 5
Expand Down Expand Up @@ -415,14 +416,14 @@ static void CScriptTypes_LoadParams_Facing(ppmfc::CComboBox& comboBox)
{
comboBox.DeleteAllStrings();

comboBox.SetItemData(comboBox.AddString("0 - NE"), 0);
comboBox.SetItemData(comboBox.AddString("1 - E"), 1);
comboBox.SetItemData(comboBox.AddString("2 - SE"), 2);
comboBox.SetItemData(comboBox.AddString("3 - S"), 3);
comboBox.SetItemData(comboBox.AddString("4 - SW"), 4);
comboBox.SetItemData(comboBox.AddString("5 - W"), 5);
comboBox.SetItemData(comboBox.AddString("6 - NW"), 6);
comboBox.SetItemData(comboBox.AddString("7 - N"), 7);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.0", "0 - NE")), 0);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.1", "1 - E")), 1);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.2", "2 - SE")), 2);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.3", "3 - S")), 3);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.4", "4 - SW")), 4);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.5", "5 - W")), 5);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.6", "6 - NW")), 6);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Facing.7", "7 - N")), 7);
}

// 16
Expand All @@ -442,10 +443,10 @@ static void CScriptTypes_LoadParams_TalkBubble(ppmfc::CComboBox& comboBox)
{
comboBox.DeleteAllStrings();

comboBox.SetItemData(comboBox.AddString("0 - None"), 0);
comboBox.SetItemData(comboBox.AddString("1 - Asterisk(*)"), 1);
comboBox.SetItemData(comboBox.AddString("2 - Question mark(?)"), 2);
comboBox.SetItemData(comboBox.AddString("3 - Exclamation mark(!)"), 3);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.TalkBubble.0", "0 - None")), 0);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.TalkBubble.1", "1 - Asterisk(*)")), 1);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.TalkBubble.2", "2 - Question mark(?)")), 2);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.TalkBubble.3", "3 - Exclamation mark(!)")), 3);
}

// 19
Expand All @@ -454,47 +455,47 @@ static void CScriptTypes_LoadParams_Status(ppmfc::CComboBox& comboBox)
comboBox.DeleteAllStrings();

int i = 0;
comboBox.SetItemData(comboBox.AddString("0 - Sleep"), i++);
comboBox.SetItemData(comboBox.AddString("1 - Attack nearest enemy"), i++);
comboBox.SetItemData(comboBox.AddString("2 - Move"), i++);
comboBox.SetItemData(comboBox.AddString("3 - QMove"), i++);
comboBox.SetItemData(comboBox.AddString("4 - Retreat home for R&R"), i++);
comboBox.SetItemData(comboBox.AddString("5 - Guard"), i++);
comboBox.SetItemData(comboBox.AddString("6 - Sticky (never recruit)"), i++);
comboBox.SetItemData(comboBox.AddString("7 - Enter object"), i++);
comboBox.SetItemData(comboBox.AddString("8 - Capture object"), i++);
comboBox.SetItemData(comboBox.AddString("9 - Move into & get eaten"), i++);
comboBox.SetItemData(comboBox.AddString("10 - Harvest"), i++);
comboBox.SetItemData(comboBox.AddString("11 - Area Guard"), i++);
comboBox.SetItemData(comboBox.AddString("12 - Return (to refinery)"), i++);
comboBox.SetItemData(comboBox.AddString("13 - Stop"), i++);
comboBox.SetItemData(comboBox.AddString("14 - Ambush (wait until discovered)"), i++);
comboBox.SetItemData(comboBox.AddString("15 - Hunt"), i++);
comboBox.SetItemData(comboBox.AddString("16 - Unload"), i++);
comboBox.SetItemData(comboBox.AddString("17 - Sabotage (move in & destroy)"), i++);
comboBox.SetItemData(comboBox.AddString("18 - Construction"), i++);
comboBox.SetItemData(comboBox.AddString("19 - Deconstruction"), i++);
comboBox.SetItemData(comboBox.AddString("20 - Repair"), i++);
comboBox.SetItemData(comboBox.AddString("21 - Rescue"), i++);
comboBox.SetItemData(comboBox.AddString("22 - Missile"), i++);
comboBox.SetItemData(comboBox.AddString("23 - Harmless"), i++);
comboBox.SetItemData(comboBox.AddString("24 - Open"), i++);
comboBox.SetItemData(comboBox.AddString("25 - Patrol"), i++);
comboBox.SetItemData(comboBox.AddString("26 - Paradrop approach drop zone"), i++);
comboBox.SetItemData(comboBox.AddString("27 - Paradrop overlay drop zone"), i++);
comboBox.SetItemData(comboBox.AddString("28 - Wait"), i++);
comboBox.SetItemData(comboBox.AddString("29 - Attack again"), i++);
comboBox.SetItemData(comboBox.AddString("30 - Spyplane approach"), i++);
comboBox.SetItemData(comboBox.AddString("31 - Spyplane overfly"), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.0", "0 - Sleep")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.1", "1 - Attack nearest enemy")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.2", "2 - Move")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.3", "3 - QMove")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.4", "4 - Retreat home for R&R")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.5", "5 - Guard")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.6", "6 - Sticky (never recruit)")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.7", "7 - Enter object")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.8", "8 - Capture object")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.9", "9 - Move into & get eaten")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.10", "10 - Harvest")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.11", "11 - Area Guard")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.12", "12 - Return (to refinery)")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.13", "13 - Stop")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.14", "14 - Ambush (wait until discovered)")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.15", "15 - Hunt")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.16", "16 - Unload")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.17", "17 - Sabotage (move in & destroy)")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.18", "18 - Construction")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.19", "19 - Deconstruction")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.20", "20 - Repair")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.21", "21 - Rescue")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.22", "22 - Missile")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.23", "23 - Harmless")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.24", "24 - Open")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.25", "25 - Patrol")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.26", "26 - Paradrop approach drop zone")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.27", "27 - Paradrop overlay drop zone")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.28", "28 - Wait")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.29", "29 - Attack again")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.30", "30 - Spyplane approach")), i++);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Status.31", "31 - Spyplane overfly")), i++);
}

// 20
static void CScriptTypes_LoadParams_Boolean(ppmfc::CComboBox& comboBox)
{
comboBox.DeleteAllStrings();

comboBox.SetItemData(comboBox.AddString("0 - FALSE"), 0);
comboBox.SetItemData(comboBox.AddString("1 - TRUE"), 1);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Boolean.0", "0 - FALSE")), 0);
comboBox.SetItemData(comboBox.AddString(Translations::TranslateOrDefault("ScriptParam.Boolean.1", "1 - TRUE")), 1);
}

};
8 changes: 5 additions & 3 deletions FA2sp/Ext/CTriggerOption/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

#include <Helpers/Macro.h>

#include "../../Helpers/Translations.h"

DEFINE_HOOK(502E66, CTriggerOption_OnInitDialog_RepeatTypeFix, 7)
{
GET(CTriggerOption*, pThis, ESI);

pThis->CCBHouse.DeleteAllStrings();
pThis->CCBRepeatType.DeleteAllStrings();

pThis->CCBRepeatType.AddString("0 - One Time OR");
pThis->CCBRepeatType.AddString("1 - One Time AND");
pThis->CCBRepeatType.AddString("2 - Repeating OR");
pThis->CCBRepeatType.AddString(Translations::TranslateOrDefault("TriggerRepeatType.OneTimeOr", "0 - One Time OR"));
pThis->CCBRepeatType.AddString(Translations::TranslateOrDefault("TriggerRepeatType.OneTimeAnd", "1 - One Time AND"));
pThis->CCBRepeatType.AddString(Translations::TranslateOrDefault("TriggerRepeatType.RepeatingOr", "2 - Repeating OR"));

return 0;
}
10 changes: 7 additions & 3 deletions FA2sp/FA2sp.Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

#define PRODUCT_MAJOR 1
#define PRODUCT_MINOR 5
#define PRODUCT_REVISION 0
#define PRODUCT_HOTFIX 0
#define PRODUCT_REVISION 1

#ifdef NDEBUG
#define PRODUCT_STR __str(PRODUCT_MAJOR) "." __str(PRODUCT_MINOR) "." __str(PRODUCT_REVISION)
#else
#define PRODUCT_STR __DATE__ " " __TIME__
#endif

#define PRODUCT_STR __str(PRODUCT_MAJOR) "." __str(PRODUCT_MINOR) "." __str(PRODUCT_REVISION) "." __str(PRODUCT_HOTFIX)
#define DISPLAY_STR PRODUCT_STR
#define PRODUCT_NAME "FA2sp"
#define VERSION_STRVER PRODUCT_NAME " " PRODUCT_STR
Expand Down
15 changes: 15 additions & 0 deletions FA2sp/Helpers/Translations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,21 @@ bool Translations::GetTranslationItem(const char* pLabelName, ppmfc::CString& re
return false;
}

const char* Translations::TranslateOrDefault(const char* lpLabelName, const char* lpDefault)
{
for (const auto& language : Translations::pLanguage)
{
if (auto section = CINI::FALanguage->GetSection(language))
{
auto itr = section->GetEntities().find(lpLabelName);
if (itr != section->GetEntities().end())
return itr->second;
}
}

return lpDefault;
}

void Translations::TranslateItem(CWnd* pWnd, int nSubID, const char* lpKey)
{
ppmfc::CString buffer;
Expand Down
1 change: 1 addition & 0 deletions FA2sp/Helpers/Translations.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Translations
static void TranslateItem(CWnd* pWnd, const char* lpKey);
static void TranslateItem(ppmfc::CWnd* pWnd, int nSubID, const char* lpKey) { TranslateItem((CWnd*)pWnd, nSubID, lpKey); }
static void TranslateItem(ppmfc::CWnd* pWnd, const char* lpKey) { TranslateItem((CWnd*)pWnd, lpKey); };
static const char* TranslateOrDefault(const char* lpLabelName, const char* lpDefault);
static char pLanguage[4][0x400];
};

0 comments on commit 3b2451b

Please sign in to comment.