-
Notifications
You must be signed in to change notification settings - Fork 8
/
Console.cpp
225 lines (187 loc) · 6.47 KB
/
Console.cpp
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
#include "Console.h"
#include "Hooks\Hooks-Plugins.h"
#include "Hooks\Hooks-Dialog.h"
#include "Achievements.h"
#include "PluginAPIManager.h"
#include "FormUndoStack.h"
#include "[BGSEEBase]\BGSEditorExtenderBase_Resource.h"
namespace cse
{
namespace console
{
void BGSEEConsoleCmd_88MPH_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
BGSEECONSOLE_MESSAGE("Great Scott! We left Copernicus in the freezer once again!");
}
void BGSEEConsoleCmd_Wubble_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
BGSEEACHIEVEMENTS->Unlock(achievements::kEruditeModder);
}
void BGSEEConsoleCmd_LoadPlugin_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
SME::StringHelpers::Tokenizer ArgParser(Args, " ,");
std::string CurrentArg;
std::string PluginName;
bool SetActive = false;
for (int i = 1; i <= ParamCount; i++)
{
ArgParser.NextToken(CurrentArg);
switch (i)
{
case 1:
PluginName = CurrentArg;
break;
case 2:
SetActive = (_stricmp(CurrentArg.c_str(), "1") == 0);
break;
}
}
// prolog
hooks::_MemHdlr(AutoLoadActivePluginOnStartup).WriteJump();
TESFile* File = _DATAHANDLER->LookupPluginByName(PluginName.c_str());
if (File)
{
File->SetActive(SetActive);
File->SetLoaded(true);
SendMessage(BGSEEUI->GetMainWindow(), WM_COMMAND, TESCSMain::kToolbar_DataFiles, 0);
}
else
BGSEECONSOLE_MESSAGE("Plugin '%s' doesn't exist!", PluginName.c_str());
// epilog
hooks::_MemHdlr(AutoLoadActivePluginOnStartup).WriteBuffer();
}
void BGSEEConsoleCmd_LoadForm_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
SME::StringHelpers::Tokenizer ArgParser(Args, " ,");
std::string CurrentArg;
std::string EditorID;
for (int i = 1; i <= ParamCount; i++)
{
ArgParser.NextToken(CurrentArg);
switch (i)
{
case 1:
EditorID = CurrentArg;
break;
}
}
TESForm* Form = TESForm::LookupByEditorID(EditorID.c_str());
if (Form)
{
TESDialog::ShowFormEditDialog(Form);
}
else
BGSEECONSOLE_MESSAGE("Couldn't load form '%s' for editing. Recheck the editorID argument.", EditorID.c_str());
}
void BGSEEConsoleCmd_SavePlugin_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
SendMessage(BGSEEUI->GetMainWindow(), WM_COMMAND, TESCSMain::kToolbar_Save, 0);
}
void BGSEEConsoleCmd_AutoSave_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
TESCSMain::AutoSave();
}
void BGSEEConsoleCmd_Exit_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
SendMessage(BGSEEUI->GetMainWindow(), WM_CLOSE, 0, 0);
}
void BGSEEConsoleCmd_Crash_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
SME::StringHelpers::Tokenizer ArgParser(Args, " ,");
std::string CurrentArg;
bool Assertion = false;
for (int i = 1; i <= ParamCount; i++)
{
ArgParser.NextToken(CurrentArg);
switch (i)
{
case 1:
Assertion = CurrentArg != "0";
break;
}
}
if (Assertion)
{
SME_ASSERT(1 == 0);
}
else
{
*((int*)0) = 0;
}
}
void BGSEEConsoleCmd_Undo_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
BGSEEUNDOSTACK->PerformUndo();
}
void BGSEEConsoleCmd_Redo_ExecuteHandler(BGSEECONSOLECMD_ARGS)
{
BGSEEUNDOSTACK->PerformRedo();
}
DEFINE_BGSEECONSOLECMD(88MPH, 0);
DEFINE_BGSEECONSOLECMD(Wubble, 0);
DEFINE_BGSEECONSOLECMD(LoadPlugin, 2);
DEFINE_BGSEECONSOLECMD(LoadForm, 1);
DEFINE_BGSEECONSOLECMD(SavePlugin, 0);
DEFINE_BGSEECONSOLECMD(AutoSave, 0);
DEFINE_BGSEECONSOLECMD(Exit, 0);
DEFINE_BGSEECONSOLECMD(Crash, 1);
DEFINE_BGSEECONSOLECMD(Undo, 0);
DEFINE_BGSEECONSOLECMD(Redo, 0);
ConsoleWarningRegistrar::~ConsoleWarningRegistrar()
{
;//
}
void ConsoleWarningRegistrar::operator()( bgsee::ConsoleWarningManager* Manager )
{
Manager->RegisterWarning(new bgsee::ConsoleWarning("28976C49-8975-49BD-83C5-871B224504A7",
"Magic Item has no effects defined",
2, 0x0056DF1D, 0x0056E32D));
Manager->RegisterWarning(new bgsee::ConsoleWarning("0240B41A-C1DF-4641-AF1C-858A32013333",
"Armor/Clothing needs to have biped slots selected in the editor",
2, 0x005162F7, 0x00517CB7));
Manager->RegisterWarning(new bgsee::ConsoleWarning("C39EB363-D4D0-4CF6-8B9F-90D57E2B5E93",
"NiControllerSequence::StoreTargets failed to find target",
4, 0x007379D3, 0x00737B75, 0x00737CF4, 0x00737E1B));
Manager->RegisterWarning(new bgsee::ConsoleWarning("2A7BBE4C-492B-4085-8DF7-62A89F393B8A",
"Duplicate base anim group in files",
2, 0x004A7E0D, 0x004A7E31));
Manager->RegisterWarning(new bgsee::ConsoleWarning("02A85697-A602-41E1-BBDC-20871BE0EC3D",
"File should/NOT be a looping animation",
1, 0x004C9E5F));
Manager->RegisterWarning(new bgsee::ConsoleWarning("7F709F5D-999D-40FF-B86A-FF17203C5676",
"Controller priority less than 0 found in sequence on bone",
1, 0x0046C7D0));
Manager->RegisterWarning(new bgsee::ConsoleWarning("9B986781-814C-478A-9D12-1BAD354F7193",
"Pathgrid for cell contains inter-grid connections",
1, 0x0054F6BE));
Manager->RegisterWarning(new bgsee::ConsoleWarning("2B3B0430-3C6B-40D9-9A8E-FED0B377CC5B",
"Bad note string in animation frame",
2, 0x004C9EBD, 0x004CA03A));
}
bool Initialized = false;
void Initialize()
{
if (settings::dialogs::kShowMainWindowsInTaskbar.GetData().i)
{
bgsee::WindowStyler::StyleData RegularAppWindow = {0};
RegularAppWindow.Extended = WS_EX_APPWINDOW;
RegularAppWindow.ExtendedOp = bgsee::WindowStyler::StyleData::kOperation_OR;
BGSEEUI->GetWindowStyler()->RegisterStyle(IDD_BGSEE_CONSOLE, RegularAppWindow);
}
BGSEECONSOLE->InitializeUI(BGSEEUI->GetMainWindow(), BGSEEMAIN->GetExtenderHandle());
BGSEECONSOLE->InitializeWarningManager(BGSEEMAIN->INIGetter(), BGSEEMAIN->INISetter(), ConsoleWarningRegistrar());
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_88MPH);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_Wubble);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_AutoSave);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_Exit);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_LoadForm);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_LoadPlugin);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_SavePlugin);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_Crash);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_Undo);
BGSEECONSOLE->RegisterConsoleCommand(&kBGSEEConsoleCmd_Redo);
PluginAPIManager::Instance.ConsumeConsoleInterface();
Initialized = true;
}
}
}