mirror of
https://github.com/oldmud0/LilithPort.git
synced 2024-11-21 22:26:16 +01:00
Improve error handling in startup and closing
This commit is contained in:
parent
7245dee9d1
commit
c07a0536a2
2 changed files with 41 additions and 24 deletions
|
@ -1520,6 +1520,9 @@ private: System::Windows::Forms::ContextMenu^ contextMenuStrip2;
|
|||
}
|
||||
|
||||
void WriteMessage(String^ msg, Color color){
|
||||
//Prevents an error writing to the chat log when you are closing the program
|
||||
if (richTextBoxLog->IsDisposed) return;
|
||||
|
||||
if(richTextBoxLog->InvokeRequired){
|
||||
WriteMessageDelegate^ wmd = gcnew WriteMessageDelegate(this, &MainForm::WriteMessage);
|
||||
richTextBoxLog->Invoke(wmd, msg, color);
|
||||
|
|
|
@ -421,33 +421,47 @@ namespace LilithPort {
|
|||
case CT_SERVER:
|
||||
default:
|
||||
radioButtonServer->Checked = true;
|
||||
|
||||
numericUpDownPort->Enabled = false;
|
||||
break;
|
||||
case CT_HOST:
|
||||
radioButtonHost->Checked = true;
|
||||
|
||||
break;
|
||||
case CT_CLIENT:
|
||||
radioButtonClient->Checked = true;
|
||||
|
||||
numericUpDownOpenPort->Enabled = false;
|
||||
break;
|
||||
}
|
||||
|
||||
bool error = false;
|
||||
|
||||
try {
|
||||
textBoxServerName->Text = gcnew String(MTOPTION.SERVER_NAME);
|
||||
textBoxIP->Text = gcnew String(MTOPTION.CONNECTION_IP);
|
||||
|
||||
|
||||
numericUpDownOpenPort->Value = MTOPTION.OPEN_PORT;
|
||||
|
||||
textBoxName->Text = gcnew String(MTOPTION.NAME);
|
||||
numericUpDownPort->Value = MTOPTION.PORT;
|
||||
numericUpDownMaxConnection->Value = MTOPTION.MAX_CONNECTION;
|
||||
|
||||
textBoxComment->Text = gcnew String(MTOPTION.COMMENT);
|
||||
textBoxWelcome->Text = gcnew String(MTOPTION.WELCOME);
|
||||
}
|
||||
catch (Exception^ e) {
|
||||
error = true;
|
||||
}
|
||||
|
||||
try {
|
||||
numericUpDownOpenPort->Value = MTOPTION.OPEN_PORT;
|
||||
numericUpDownPort->Value = MTOPTION.PORT;
|
||||
numericUpDownMaxConnection->Value = MTOPTION.MAX_CONNECTION;
|
||||
}
|
||||
catch (Exception^ e) {
|
||||
numericUpDownOpenPort->Value = 7500;
|
||||
numericUpDownOpenPort->Value = 7500;
|
||||
numericUpDownMaxConnection->Value = 4;
|
||||
error = true;
|
||||
}
|
||||
|
||||
if (error) {
|
||||
MessageBox::Show(L"Some options could not be loaded correctly from the settings file. Their default values have been loaded instead.", L"Settings File Corrupt", MessageBoxButtons::OK, MessageBoxIcon::Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
System::Void StartupForm_Shown(System::Object^ sender, System::EventArgs^ e) {
|
||||
buttonOK->Focus();
|
||||
|
|
Loading…
Reference in a new issue