mirror of
https://github.com/oldmud0/LilithPort.git
synced 2024-12-22 14:35:39 +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);
|
||||
|
|
|
@ -418,35 +418,49 @@ namespace LilithPort {
|
|||
textBoxComment->MaxLength = MAX_NAME;
|
||||
|
||||
switch(MTOPTION.CONNECTION_TYPE){
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
textBoxServerName->Text = gcnew String(MTOPTION.SERVER_NAME);
|
||||
textBoxIP->Text = gcnew String(MTOPTION.CONNECTION_IP);
|
||||
bool error = false;
|
||||
|
||||
try {
|
||||
textBoxServerName->Text = gcnew String(MTOPTION.SERVER_NAME);
|
||||
textBoxIP->Text = gcnew String(MTOPTION.CONNECTION_IP);
|
||||
textBoxName->Text = gcnew String(MTOPTION.NAME);
|
||||
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;
|
||||
}
|
||||
|
||||
numericUpDownOpenPort->Value = MTOPTION.OPEN_PORT;
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
System::Void StartupForm_Shown(System::Object^ sender, System::EventArgs^ e) {
|
||||
|
|
Loading…
Reference in a new issue