Skip to content

Commit

Permalink
Added configurable age labels
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWichelmann committed Dec 29, 2017
1 parent 4752c5b commit 302a326
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions AoKHBlacksmith.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ This software is published under the MIT/X11 license. Please read the LICENSE fo

[b]Updates[/b]

[u]1.2.5[/u]
- The DLL-IDs of the labels below the age emblems are no longer hardcoded (useful for mods that change age names to something that doesn't end with "Age", like "Renaissance")
Note: This update breaks compatibility with files that were created with a version prior to 1.2.2; use one of the versions 1.2.2-1.2.4 to convert those files first!

[u]1.2.4[/u]
View:
- Fixed crash when opening the tech tree during a game (thanks to danielpereira for reporting it and providing test data)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015-2017 Jan Wichelmann
Copyright (c) 2015-2018 Jan Wichelmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
9 changes: 8 additions & 1 deletion TechTree/TechTreeDesign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ extern int(__cdecl *ReadDataFromCompressedFile)(int fileHandle, char *dataBuffer
TechTreeDesign::TechTreeDesign(int datFileHandle)
{
// Read and check version marker
const unsigned char TECH_TREE_DESIGN_VERSION = 1;
const unsigned char TECH_TREE_DESIGN_VERSION = 2;
unsigned char techTreeDesignVersion;
ReadDataFromCompressedFile(datFileHandle, reinterpret_cast<char *>(&techTreeDesignVersion), 1);
if(techTreeDesignVersion != TECH_TREE_DESIGN_VERSION)
Expand Down Expand Up @@ -108,6 +108,13 @@ TechTreeDesign::TechTreeDesign(int datFileHandle)
ReadDataFromCompressedFile(datFileHandle, reinterpret_cast<char *>(&nodeBackgroundCount), 4);
for(int i = 0; i < nodeBackgroundCount; i++)
_nodeTypes.push_back(new NodeType(datFileHandle));

// Read age label data
ReadDataFromCompressedFile(datFileHandle, reinterpret_cast<char *>(&_firstLineBaseDllId), 4);
ReadDataFromCompressedFile(datFileHandle, reinterpret_cast<char *>(&_secondLineDllId), 4);
char tmp;
ReadDataFromCompressedFile(datFileHandle, &tmp, 1);
_incrementSecondLineDllId = tmp > 0;
}

TechTreeDesign::~TechTreeDesign()
Expand Down
9 changes: 9 additions & 0 deletions TechTree/TechTreeDesign.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,15 @@ class TechTreeDesign
// The first three indices match the TechTreeElement::ItemType members, so each node type has a default background design.
std::vector<NodeType *> _nodeTypes;

// The base DLL ID of the first line of the age labels.
int _firstLineBaseDllId;

// The DLL ID of the second line of the age labels.
int _secondLineDllId;

// Determines whether the DLL ID of the second line of the age labels should be incremented for each age (like the first line ID)
bool _incrementSecondLineDllId;

public:
// Constructor. Reads the tech tree element data from the given DAT file handle.
// Parameters:
Expand Down
8 changes: 4 additions & 4 deletions TechTree/TechTreeWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,10 @@ TechTreeWindow *TechTreeWindow::Constructor(Window *underlyingWindow, int unknow
}

// Set label texts
static_cast<LabelControlVTable *>(_ageLabels[i][0][0]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][0][0], 20110 + i);
static_cast<LabelControlVTable *>(_ageLabels[i][0][1]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][0][1], 20114);
static_cast<LabelControlVTable *>(_ageLabels[i][1][0]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][1][0], 20110 + i);
static_cast<LabelControlVTable *>(_ageLabels[i][1][1]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][1][1], 20114);
static_cast<LabelControlVTable *>(_ageLabels[i][0][0]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][0][0], _designData->_firstLineBaseDllId + i);
static_cast<LabelControlVTable *>(_ageLabels[i][0][1]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][0][1], _designData->_secondLineDllId + (_designData->_incrementSecondLineDllId ? i : 0));
static_cast<LabelControlVTable *>(_ageLabels[i][1][0]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][1][0], _designData->_firstLineBaseDllId + i);
static_cast<LabelControlVTable *>(_ageLabels[i][1][1]->_VTable)->AssignTextFromLanguageDlls(_ageLabels[i][1][1], _designData->_secondLineDllId + (_designData->_incrementSecondLineDllId ? i : 0));
}

// Create popup label
Expand Down

0 comments on commit 302a326

Please sign in to comment.