示例#1
0
文件: gui.cpp 项目: HeavenIsLost/rme
Editor* GUI::GetCurrentEditor()
{
	MapTab* mapTab = GetCurrentMapTab();
	if(mapTab)
		return mapTab->GetEditor();
	return nullptr;
}
示例#2
0
void MapTabbook::OnNotebookPageClose(wxAuiNotebookEvent& evt)
{
	EditorTab* editorTab = GetTab(evt.GetInt());

	MapTab* mapTab = dynamic_cast<MapTab*>(editorTab);
	if(mapTab && mapTab->IsUniqueReference() && mapTab->GetMap()) {
		if(mapTab->GetEditor()->IsLive()) {
			if(mapTab->GetMap()->hasChanged()) {
				SetFocusedTab(evt.GetInt());
				if(gui.root->DoQuerySave(false)) {
					gui.RefreshPalettes(nullptr, false);
					gui.UpdateMenus();
				} else {
					evt.Veto();
				}
			} else {
				gui.RefreshPalettes(nullptr, false);
				gui.UpdateMenus();
			}
		}
		return;
	}

	LiveLogTab* lt = dynamic_cast<LiveLogTab*>(editorTab);
	if(lt && lt->IsConnected()) {
		evt.Veto();
	}
}
示例#3
0
文件: gui.cpp 项目: HeavenIsLost/rme
void GUI::CreateLoadBar(wxString message, bool canCancel /* = false */ )
{
	progressText = message;

	progressFrom = 0;
	progressTo = 100;
	currentProgress = -1;

	progressBar = newd wxGenericProgressDialog(wxT("Loading"), progressText + wxT(" (0%)"), 100, root,
		wxPD_APP_MODAL | wxPD_SMOOTH | (canCancel ? wxPD_CAN_ABORT : 0)
	);
	progressBar->SetSize(280, -1);
	progressBar->Show(true);

	for(int idx = 0; idx < tabbook->GetTabCount(); ++idx) {
		MapTab* mt = dynamic_cast<MapTab*>(tabbook->GetTab(idx));
		if(mt && mt->GetEditor()->IsLiveServer())
			mt->GetEditor()->GetLiveServer()->startOperation(progressText);
	}
	progressBar->Update(0);
}
示例#4
0
文件: gui.cpp 项目: HeavenIsLost/rme
bool GUI::SetLoadDone(int32_t done, const wxString& newMessage)
{
	if(done == 100) {
		DestroyLoadBar();
		return true;
	} else if(done == currentProgress) {
		return true;
	}

	if(!newMessage.empty()) {
		progressText = newMessage;
	}

	int32_t newProgress = progressFrom + static_cast<int32_t>((done / 100.f) * (progressTo - progressFrom));
	newProgress = std::max<int32_t>(0, std::min<int32_t>(100, newProgress));

	bool skip = false;
	if(progressBar) {
		progressBar->Update(
			newProgress,
			wxString::Format(wxT("%s (%d%%)"), progressText, newProgress),
			&skip
		);
		currentProgress = newProgress;
	}

	for(int32_t index = 0; index < tabbook->GetTabCount(); ++index) {
		MapTab* mapTab = dynamic_cast<MapTab*>(tabbook->GetTab(index));
		if(mapTab && mapTab->GetEditor()) {
			LiveServer* server = mapTab->GetEditor()->GetLiveServer();
			if(server) {
				server->updateOperation(newProgress);
			}
		}
	}

	return skip;
}
示例#5
0
文件: gui.cpp 项目: HeavenIsLost/rme
bool GUI::CloseLiveEditors(LiveSocket* sock)
{
	for(int i = 0; i < tabbook->GetTabCount(); ++i) {
		MapTab* mapTab = dynamic_cast<MapTab*>(tabbook->GetTab(i));
		if(mapTab) {
			Editor* editor = mapTab->GetEditor();
			if(editor->GetLiveClient() == sock)
				tabbook->DeleteTab(i--);
		}
		LiveLogTab* liveLogTab = dynamic_cast<LiveLogTab*>(tabbook->GetTab(i));
		if(liveLogTab) {
			if(liveLogTab->GetSocket() == sock) {
				liveLogTab->Disconnect();
				tabbook->DeleteTab(i--);
			}
		}
	}
	root->UpdateMenubar();
	return true;
}
示例#6
0
文件: gui.cpp 项目: HeavenIsLost/rme
void GUI::DoPaste()
{
	MapTab* mapTab = GetCurrentMapTab();
	if(mapTab)
		copybuffer.paste(*mapTab->GetEditor(), mapTab->GetCanvas()->GetCursorPosition());
}