forked from AthenaADP/MHW-ASS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Common.h
309 lines (269 loc) · 7.29 KB
/
Common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
#pragma once
enum class Gender { MALE = 4, FEMALE, BOTH_GENDERS };
#define List_t System::Collections::Generic::List
#define Map_t System::Collections::Generic::Dictionary
//#define CREATE_MATERIALS
ref struct Armor;
ref struct Ability;
ref struct Decoration;
ref struct AbilityPair;
ref struct Skill;
ref struct Charm;
ref struct AdvancedSearchOptions abstract
{
bool force_enable, force_disable, default_piece;
unsigned adv_index;
};
namespace Utility
{
template< class T >
bool Contains( List_t< T^ >^ cont, const T^ val )
{
for( int i = 0; i < cont->Count; ++i )
{
if( cont[ i ] == val )
return true;
}
return false;
}
bool Contains( List_t< Skill^ >^ cont, const Ability^ val );
template< class T >
bool Contains( array< T^ >^ cont, const T^ val )
{
for( int i = 0; i < cont->Length; ++i )
{
if( cont[ i ] == val )
return true;
}
return false;
}
template< class T >
int GetIndexOf( List_t< T^ >^ cont, const T^ val )
{
for( int i = 0; i < cont->Count; ++i )
{
if( cont[ i ] == val )
return i;
}
return -1;
}
void AddAbilitiesToMap( List_t< AbilityPair^ >% _list, Map_t< Ability^, unsigned >% _map, const int mult = 1 );
unsigned CountChars( System::String^ str, const wchar_t c );
bool ContainsString( List_t< System::String^ >% vec, System::String^ item );
void SplitString( List_t< System::String^ >^ vec, System::String^ str, const wchar_t c );
void FindLevelReqs( unsigned% available, unsigned% required, System::String^ input );
System::String^ RemoveQuotes( System::String^ in_out );
inline unsigned Min( const unsigned a, const unsigned b ) { return a > b ? b : a; }
void UpdateContextMenu( System::Windows::Forms::ContextMenuStrip^ strip, Decoration^ decoration );
void UpdateContextMenu( System::Windows::Forms::ContextMenuStrip^ strip, Armor^ armor, const bool use_aug_defence );
void UpdateContextMenu( System::Windows::Forms::ContextMenuStrip^ strip, Ability^ ability );
void UpdateContextMenu( System::Windows::Forms::ContextMenuStrip^ strip, Charm^ charm );
}
//bool CanDisplayString( System::String^ text );
void myassert( const bool val, System::String^ message );
void myassert( const bool val, System::String^ message, System::String^ suffix_copy );
#ifdef _DEBUG
#define Assert( CONDITION, MESSAGE ) myassert( !!(CONDITION), MESSAGE )
#define AssertCopy( CONDITION, MESSAGE, COPY_TEXT_TO_CLIPBOARD ) myassert( !!(CONDITION), MESSAGE, COPY_TEXT_TO_CLIPBOARD )
#else
#define Assert( X, Y )
#define AssertCopy( X, Y, Z )
#endif
inline int Min( const int a, const int b )
{
return a > b ? b : a;
}
inline int Clamp( const int val, const int min, const int max )
{
return System::Math::Max( System::Math::Min( val, max ), min );
}
ref struct Material
{
System::String^ name;
bool event_only, arena;
unsigned difficulty;
static List_t< Material^ > static_materials;
static Material^ FindMaterial( System::String^ name );
static void LoadMaterials( System::String^ filename );
static void LoadLanguage( System::String^ filename );
static Map_t< System::String^, Material^ > static_material_map;
};
ref struct MaterialComponent
{
Material^ material;
unsigned amount;
};
ref class SuspendUpdate
{
private:
const static int WM_SETREDRAW = 0x000B;
public:
static void Suspend( System::Windows::Forms::Control^ c )
{
using namespace System;
using namespace System::Windows::Forms;
Message^ m = Message::Create( c->Handle, WM_SETREDRAW, IntPtr::Zero, IntPtr::Zero );
NativeWindow^ w = NativeWindow::FromHandle( c->Handle );
w->DefWndProc( *m );
for each( Control^ child in c->Controls )
{
Suspend( child );
}
}
static void Resume( System::Windows::Forms::Control^ c )
{
using namespace System;
using namespace System::Windows::Forms;
Message^ m = Message::Create( c->Handle, WM_SETREDRAW, IntPtr( 1 ), IntPtr::Zero );
NativeWindow^ w = NativeWindow::FromHandle( c->Handle );
w->DefWndProc( *m );
c->Invalidate();
for each( Control^ child in c->Controls )
{
Resume( child );
}
}
};
ref struct StringTable
{
static array< System::String^ >^ text;
static void LoadLanguage( System::String^ lang );
enum class StringIndex
{
TranslationCredit = 0,
File,
Options,
Language,
Help,
LoadData,
SaveData,
Update,
Exit,
ClearSettings,
AllowArena,
AllowEventArmor,
AllowFairWind,
AllowLowerTierArmor,
AlwaysSearchAlpha,
EnableAll,
DisableAll,
SortSkillsAlphabetically,
Donate,
SkillHelp,
SkillHelpForm,
CheckForUpdates,
About,
AboutForm,
MyDecorationsButton,
MyDecorationsForm,
Import,
QuickSearch,
AdvancedSearchButton,
AdvancedSearchForm,
Cancel,
Default,
AdvancedNone,
SortByNone,
Search,
SelectNone,
SelectBest,
AddNewDecoration,
ResetDecoration,
DeleteDecoration,
DeleteAllDecorations,
MoveUp,
MoveDown,
Close,
FindNext,
HR,
WeaponSlots,
Gender,
Male,
Female,
NoExtraSkillFiltering,
SortFilterResults,
DragonRes,
FireRes,
IceRes,
ThunderRes,
WaterRes,
BaseDefence,
MaxDefence,
AugDefence,
Difficulty,
Rarity,
SortSlotsSpare,
SortFamily,
SortExtraSkills,
Decorations,
UseNoDecorations,
UseOnlyMyDecorations,
UseAllDecorations,
Skill,
Skills,
SkillFilters,
SelectArmor,
Slots,
SlotLevel,
NoneBrackets,
SlotsSpare,
SolutionsFound,
ShowingFirstSolutionsOnly,
MyDecorationList,
FileCorrupted,
Version,
Find,
Error,
To,
Defence,
Results,
DeleteAllDecorationsMessage,
ASSSettings,
MaxResults,
PrintDecoNames,
PrintMaterials,
Zoom,
DefEleAbbrev,
JewelFormat,
ItemType,
SkillPossible,
Show,
Description,
SkillsHelp,
SkillTrees,
ArmorsWithSkill,
ArmorsWithSetSkill,
HRNum,
HRAll,
AreYouSure,
SkillLevel,
SlotString,
NumDecorations,
ExcludeSkill,
Completed,
SlotLevelPrefix,
TipResults,
TipDecorations,
TipFilter,
TipSort,
TipQuestLevel,
TipWeaponSlotLevel,
TipRemoveSkills,
TipAddSkills,
NumStrings
};
};
void SuspendDrawing( System::Windows::Forms::Control^ control );
void ResumeDrawing( System::Windows::Forms::Control^ control );
bool ConvertInt( int% i, System::String^ str, StringTable::StringIndex err );
bool ConvertUInt( unsigned% i, System::String^ str, StringTable::StringIndex err );
System::String^ StripAmpersands( System::String^ input );
#define StaticString( X ) StringTable::text[ (int)StringTable::StringIndex::X ]
#define StartString( X ) StaticString( X ) + L" "
#define BasicString( X ) StripAmpersands( StaticString( X ) )
#define ColonString( X ) StaticString( X ) + L": "
#define FormatString1( ID, V ) StaticString( ID )->Replace( L"%1", V )
#define FormatString2( ID, V1, V2 ) StaticString( ID )->Replace( L"%1", Convert::ToString( V1 ) )->Replace( L"%2", Convert::ToString( V2 ) )
#define FormatString3( ID, V1, V2, V3 ) StaticString( ID )->Replace( L"%1", Convert::ToString( V1 ) )->Replace( L"%2", Convert::ToString( V2 ) )->Replace( L"%3", Convert::ToString( V3 ) )
#define FormatString7( ID, A, B, C, D, E, F, G ) StaticString( ID )->Replace( L"%1", Convert::ToString( A ) )->Replace( L"%2", Convert::ToString( B ) )->Replace( L"%3", Convert::ToString( C ) )->Replace( L"%4", Convert::ToString( D ) )->Replace( L"%5", Convert::ToString( E ) )->Replace( L"%6", Convert::ToString( F ) )->Replace( L"%7", Convert::ToString( G ) )
#define FormatStringN( ID, V ) StaticString( ID )->Replace( L"%1", Convert::ToString( V ) )