示例#1
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();
	}
}
示例#2
0
文件: gui.cpp 项目: HeavenIsLost/rme
bool GUI::LoadMap(FileName name)
{
	if(GetCurrentEditor() && !GetCurrentMap().hasChanged() && !GetCurrentMap().hasFile())
		g_gui.CloseCurrentEditor();

	Editor* editor;
	try
	{
		editor = newd Editor(copybuffer, name);
	}
	catch(std::runtime_error& e)
	{
		PopupDialog(root, wxT("Error!"), wxString(e.what(), wxConvUTF8), wxOK);
		return false;
	}

	MapTab* mapTab = newd MapTab(tabbook, editor);
	mapTab->OnSwitchEditorMode(mode);

	root->AddRecentFile(name);

	mapTab->GetView()->FitToMap();
	UpdateTitle();
	ListDialog(wxT("Map loader errors"), mapTab->GetMap()->getWarnings());
	root->DoQueryImportCreatures();

	FitViewToMap(mapTab);
	root->UpdateMenubar();
	return true;
}
示例#3
0
void MapTabbook::OnNotebookPageChanged(wxAuiNotebookEvent& evt)
{
	gui.UpdateMinimap();

	int32_t oldSelection = evt.GetOldSelection();
	int32_t newSelection = evt.GetSelection();

	MapTab* oldMapTab;
	if(oldSelection != -1) {
		oldMapTab = dynamic_cast<MapTab*>(GetTab(oldSelection));
	} else {
		oldMapTab = nullptr;
	}

	MapTab* newMapTab;
	if(newSelection != -1) {
		newMapTab = dynamic_cast<MapTab*>(GetTab(newSelection));
	} else {
		newMapTab = nullptr;
	}

	// std::cout << oldSelection << " " << newSelection;
	if(!newMapTab) {
		gui.RefreshPalettes(nullptr);
	} else if(!oldMapTab || !oldMapTab->HasSameReference(newMapTab)) {
		gui.RefreshPalettes(newMapTab->GetMap());
		gui.UpdateMenus();
	}
}
示例#4
0
文件: gui.cpp 项目: HeavenIsLost/rme
bool GUI::CloseAllEditors()
{
	for(int i = 0; i < tabbook->GetTabCount(); ++i) {
		MapTab* mapTab = dynamic_cast<MapTab*>(tabbook->GetTab(i));
		if(mapTab) {
			if(mapTab->IsUniqueReference() && mapTab->GetMap() && mapTab->GetMap()->hasChanged()) {
				tabbook->SetFocusedTab(i);
				if(!root->DoQuerySave(false)) {
					return false;
				} else {
					RefreshPalettes();
					tabbook->DeleteTab(i--);
				}
			} else {
				tabbook->DeleteTab(i--);
			}
		}
	}
	if(root)
		root->UpdateMenubar();
	return true;
}
示例#5
0
文件: gui.cpp 项目: HeavenIsLost/rme
int GUI::GetOpenMapCount()
{
	std::set<Map*> open_maps;

	for(int i = 0; i < tabbook->GetTabCount(); ++i) {
		MapTab* tab = dynamic_cast<MapTab*>(tabbook->GetTab(i));
		if(tab)
			open_maps.insert(open_maps.begin(), tab->GetMap());

	}

	return open_maps.size();
}