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 Aug 20, 2021
2 parents 75ac312 + 5d59368 commit e78ff24
Show file tree
Hide file tree
Showing 13 changed files with 532 additions and 38 deletions.
2 changes: 1 addition & 1 deletion FA2pp
Submodule FA2pp updated 1 files
+8 −8 CAITriggerTypes.h
4 changes: 4 additions & 0 deletions FA2sp.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<ItemGroup>
<ClCompile Include="FA2pp\FunctionInit.cpp" />
<ClCompile Include="FA2sp\ExtraWindow\CAllieEditor\CAllieEditor.cpp" />
<ClCompile Include="FA2sp\Ext\CAITriggerTypes\Body.cpp" />
<ClCompile Include="FA2sp\Ext\CFinalSunDlg\Body.cpp" />
<ClCompile Include="FA2sp\Ext\CFinalSunDlg\Body.ObjectBrowserControl.cpp" />
<ClCompile Include="FA2sp\Ext\CFinalSunDlg\Hooks.cpp" />
Expand All @@ -149,6 +150,7 @@
<ClCompile Include="FA2sp\Hooks.Debug.cpp" />
<ClCompile Include="FA2sp\Miscs\DrawStuff.cpp" />
<ClCompile Include="FA2sp\Miscs\Exception.cpp" />
<ClCompile Include="FA2sp\Miscs\Hooks.SaveMap.cpp" />
<ClCompile Include="FA2sp\Miscs\Palettes.cpp" />
<ClCompile Include="FA2sp\UI\UIColor.cpp" />
<ClCompile Include="FA2sp\Miscs\Hooks.BugFixes.cpp" />
Expand Down Expand Up @@ -176,6 +178,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="FA2sp\ExtraWindow\CAllieEditor\CAllieEditor.h" />
<ClInclude Include="FA2sp\Ext\CAITriggerTypes\Body.h" />
<ClInclude Include="FA2sp\Ext\CFinalSunDlg\Body.h" />
<ClInclude Include="FA2sp\Ext\CHouses\Body.h" />
<ClInclude Include="FA2sp\Ext\CIsoView\Body.h" />
Expand Down Expand Up @@ -213,6 +216,7 @@
<ItemGroup>
<ResourceCompile Include="FA2sp\ExtraWindow\CAllieEditor\CAllieEditor.rc" />
<ResourceCompile Include="FA2sp\UI\CAircraftDialog.rc" />
<ResourceCompile Include="FA2sp\UI\CAITriggerTypes.rc" />
<ResourceCompile Include="FA2sp\UI\CInfantryDialog.rc" />
<ResourceCompile Include="FA2sp\UI\CMenu.rc" />
<ResourceCompile Include="FA2sp\UI\CScriptTypes.rc" />
Expand Down
12 changes: 12 additions & 0 deletions FA2sp.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@
<ClInclude Include="FA2sp\Miscs\Exception.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="FA2sp\Ext\CAITriggerTypes\Body.h">
<Filter>头文件</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="FA2sp\FA2sp.cpp">
Expand Down Expand Up @@ -275,6 +278,12 @@
<ClCompile Include="FA2sp\Miscs\Exception.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="FA2sp\Miscs\Hooks.SaveMap.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="FA2sp\Ext\CAITriggerTypes\Body.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="FA2sp\FA2sp.rc">
Expand Down Expand Up @@ -328,5 +337,8 @@
<ResourceCompile Include="FA2sp\ExtraWindow\CAllieEditor\CAllieEditor.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
<ResourceCompile Include="FA2sp\UI\CAITriggerTypes.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
116 changes: 109 additions & 7 deletions FA2sp/Ext/CAITriggerTypes/Body.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,120 @@
#include "Body.h"

CAITriggerTypes* CAITriggerTypesExt::Instance = nullptr;
#include <CINI.h>
#include <GlobalVars.h>

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

void CAITriggerTypesExt::ProgramStartupInit()
{
RunTime::ResetMemoryContentAt(0x591B08, CAITriggerTypesExt::PreTranslateMessageExt);
RunTime::ResetMemoryContentAt(0x591B34, &CAITriggerTypesExt::OnInitDialogExt);
RunTime::ResetMemoryContentAt(0x591B08, &CAITriggerTypesExt::PreTranslateMessageExt);
}

BOOL CAITriggerTypesExt::PreTranslateMessageExt(MSG* pMsg)
BOOL CAITriggerTypesExt::OnInitDialogExt()
{
switch (pMsg->message) {
BOOL ret = this->CAITriggerTypes::OnInitDialog();
if (!ret)
return FALSE;

Translations::TranslateItem(this, "AITriggerTitle");
Translations::TranslateItem(this, 50900, "AITriggerList");
Translations::TranslateItem(this, 50901, "AITriggerName");
Translations::TranslateItem(this, 50902, "AITriggerTeam1");
Translations::TranslateItem(this, 50903, "AITriggerHouse");
Translations::TranslateItem(this, 50904, "AITriggerTeam2");
Translations::TranslateItem(this, 50905, "AITriggerTechlevel");
Translations::TranslateItem(this, 50906, "AITriggerType");
Translations::TranslateItem(this, 50907, "AITriggerWeight");
Translations::TranslateItem(this, 50908, "AITriggerMinWeight");
Translations::TranslateItem(this, 50909, "AITriggerMaxWeight");
Translations::TranslateItem(this, 50910, "AITriggerMinDiff");
Translations::TranslateItem(this, 50911, "AITriggerSide");
Translations::TranslateItem(this, 50912, "AITriggerTechnoType");
Translations::TranslateItem(this, 50913, "AITriggerCondition");
Translations::TranslateItem(this, 50914, "AITriggerNumber");
Translations::TranslateItem(this, 50915, "AITriggerAdditionalDesc");
Translations::TranslateItem(this, 1210, "AITriggerData");

Translations::TranslateItem(this, 1218, "AITriggerEnabled");
Translations::TranslateItem(this, 1154, "AITriggerAdd");
Translations::TranslateItem(this, 1066, "AITriggerDel");
Translations::TranslateItem(this, 1919, "AITriggerClo");
Translations::TranslateItem(this, 1452, "AITriggerBaseDefense");
Translations::TranslateItem(this, 1453, "AITriggerSkirmish");
Translations::TranslateItem(this, 1424, "AITriggerEasy");
Translations::TranslateItem(this, 1425, "AITriggerMedium");
Translations::TranslateItem(this, 1426, "AITriggerHard");

default:
break;
HWND hSides;
GetDlgItem(1456, &hSides);
while (::SendMessage(hSides, CB_DELETESTRING, 0, NULL) != CB_ERR);

::SendMessage(hSides, CB_ADDSTRING, NULL, (LPARAM)"0 - All");
int i = 1;
if (auto sides = GlobalVars::INIFiles::FAData->GetSection("Sides"))
{
for (auto& itr : sides->EntitiesDictionary)
{
ppmfc::CString buffer;
buffer.Format("%d - %s", i++, itr.second);
::SendMessage(hSides, CB_ADDSTRING, NULL, (LPARAM)buffer.m_pchData);
}
}

return TRUE;
}

BOOL CAITriggerTypesExt::PreTranslateMessageExt(MSG* pMsg)
{
switch (pMsg->message)
{
case WM_LBUTTONUP:
{
if (pMsg->hwnd == this->GetDlgItem(1919)->GetSafeHwnd())
this->OnBNCloneAITriggerClicked();
}
}

return this->FA2CDialog::PreTranslateMessage(pMsg);
}
}

void CAITriggerTypesExt::OnBNCloneAITriggerClicked()
{
if (this->CCBAITriggerList.GetCount() > 0 && this->CCBAITriggerList.GetCurSel() != CB_ERR)
{
ppmfc::CString currentID;
this->CCBAITriggerList.GetWindowText(currentID);
STDHelpers::TrimIndex(currentID);

ppmfc::CString key = INIClass::GetAvailableIndex();
ppmfc::CString value, name;

HWND hName;
GetDlgItem(1010, &hName);
auto nLen = ::GetWindowTextLength(hName);
auto pStr = new char[nLen + 1];
::GetWindowText(hName, pStr, nLen + 1);
name.Format("%s Clone", pStr);
delete[] pStr;

value = name + ",";
auto& results = STDHelpers::SplitString(GlobalVars::INIFiles::CurrentDocument->GetString("AITriggerTypes", currentID));
for (int i = 1; i < results.size() - 1; ++i)
value += (results[i] + ",");
value += results.back();

GlobalVars::INIFiles::CurrentDocument->WriteString("AITriggerTypes", key, value);

GlobalVars::INIFiles::CurrentDocument->WriteString(
"AITriggerTypesEnable", key,
GlobalVars::INIFiles::CurrentDocument->GetString("AITriggerTypesEnable", currentID, "no")
);

int idx = this->CCBAITriggerList.AddString(key + " (" + name + ")");
this->CCBAITriggerList.SetCurSel(idx);

this->SetDlgItemText(1010, name); // update the name huh
}
}
12 changes: 6 additions & 6 deletions FA2sp/Ext/CAITriggerTypes/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
class NOVTABLE CAITriggerTypesExt : public CAITriggerTypes
{
public:
typedef BOOL(*FuncT_PTM)(MSG* pMsg);

static CAITriggerTypes* Instance;
static void ProgramStartupInit();

//hook function to replace in virtual function map
//
// Ext Functions
//
BOOL OnInitDialogExt();
BOOL PreTranslateMessageExt(MSG* pMsg);

static void ProgramStartupInit();

CAITriggerTypesExt() {};
~CAITriggerTypesExt() {};

void OnBNCloneAITriggerClicked();
private:

};
1 change: 1 addition & 0 deletions FA2sp/Ext/FA2Expand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

void __stdcall FA2Expand::ExeRun()
{
CAITriggerTypesExt::ProgramStartupInit();
CFinalSunDlgExt::ProgramStartupInit();
CHousesExt::ProgramStartupInit();
// CIsoViewExt::ProgramStartupInit();
Expand Down
11 changes: 3 additions & 8 deletions FA2sp/FA2sp.Constants.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
#pragma once

#define wstr(x) wstr_(x)
#define wstr_(x) L ## #x
#define str(x) str_(x)
#define str_(x) #x

constexpr int PRODUCT_MAJOR = 1;
constexpr int PRODUCT_MINOR = 0;
constexpr int PRODUCT_REVISION = 3;
constexpr char* PRODUCT_STR = "1.0.3";
constexpr char* PRODUCT_STR = "1.0.4";
constexpr char* DISPLAY_STR = PRODUCT_STR;
constexpr char* VERSION_STRVER = "FA2sp 1.0.3";
constexpr char* VERSION_STRVER = "FA2sp 1.0.4";

constexpr char* PRODUCT_NAME = "FA2sp";
constexpr char* APPLY_INFO = "Found Final Alert 2 version 1.02. Applying FA2sp 1.0.3.";
constexpr char* APPLY_INFO = "Found Final Alert 2 version 1.02. Applying FA2sp 1.0.4.";
// constexpr char* APPLY_INFO = "Found Final Alert 2 version 1.02. Applying FA2sp - " __DATE__ " - " __TIME__;

constexpr char* MUTEX_HASH_VAL = "b8097bca8590a4f46c975ebb43503aab2243ce7f1c87f12f7984dbe1";
Expand Down
17 changes: 17 additions & 0 deletions FA2sp/FA2sp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ int ExtConfigs::Waypoint_Background_Color;
bool ExtConfigs::ExtWaypoints;
int ExtConfigs::UndoRedoLimit;
bool ExtConfigs::UseRGBHouseColor;
bool ExtConfigs::SaveMap;
bool ExtConfigs::SaveMap_AutoSave;
int ExtConfigs::SaveMap_AutoSave_Interval;
int ExtConfigs::SaveMap_AutoSave_MaxCount;

MultimapHelper Variables::Rules = { &GlobalVars::INIFiles::Rules(), &GlobalVars::INIFiles::CurrentDocument() };

Expand Down Expand Up @@ -81,6 +85,19 @@ void FA2sp::ExtConfigsInitialize()
ExtConfigs::UndoRedoLimit = fadata.GetInteger("ExtConfigs", "UndoRedoLimit", 16);

ExtConfigs::UseRGBHouseColor = fadata.GetBool("ExtConfigs", "UseRGBHouseColor");

if (ExtConfigs::SaveMap = fadata.GetBool("ExtConfigs", "SaveMap"))
{
if (ExtConfigs::SaveMap_AutoSave = fadata.GetBool("ExtConfigs", "SaveMap.AutoSave"))
{
ExtConfigs::SaveMap_AutoSave_Interval = fadata.GetInteger("ExtConfigs", "SaveMap.AutoSave.Interval", 300);
ExtConfigs::SaveMap_AutoSave_MaxCount = fadata.GetInteger("ExtConfigs", "SaveMap.AutoSave.MaxCount", 10);
}
else
{
ExtConfigs::SaveMap_AutoSave_Interval = -1;
}
}
}

// DllMain
Expand Down
4 changes: 4 additions & 0 deletions FA2sp/FA2sp.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class ExtConfigs
static bool ExtWaypoints;
static int UndoRedoLimit;
static bool UseRGBHouseColor;
static bool SaveMap;
static bool SaveMap_AutoSave;
static int SaveMap_AutoSave_Interval;
static int SaveMap_AutoSave_MaxCount;
};

class Variables
Expand Down
12 changes: 6 additions & 6 deletions FA2sp/Miscs/Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,10 @@ std::wstring Exception::FullDump(
}

//ifdef DUMP_EXTENSIVE
DEFINE_HOOK(434920, Exception_Handler, 7)
{
//GET(int, code, ECX);
GET(LPEXCEPTION_POINTERS, pExs, EDX);
Exception::ExceptionHandler(pExs);
}
//DEFINE_HOOK(434920, Exception_Handler, 7)
//{
// //GET(int, code, ECX);
// GET(LPEXCEPTION_POINTERS, pExs, EDX);
// Exception::ExceptionHandler(pExs);
//}
//endif
Loading

0 comments on commit e78ff24

Please sign in to comment.