extern "C" WXEXPORT wxc_bool wxComboBox_Create(wxComboBox* self, wxWindow* window, int id, wxc_string value, const wxPoint* pos, const wxSize* size, int n, wxc_string choices[], long style, const wxValidator* validator, wxc_string name) { int i; if (pos == NULL) pos = &wxDefaultPosition; if (size == NULL) size = &wxDefaultSize; if (validator == NULL) validator = &wxDefaultValidator; if (name.data==NULL) name = wxc_string("comboBox"); wxString* strings = new wxString[n]; for (i = 0; i < n; ++i) strings[i] = wxstr(choices[i]); return self->Create(window, id, wxstr(value), *pos, *size, n, strings, style, *validator, wxstr(name))?1:0; }
extern "C" WXEXPORT wxc_bool wxListBox_Create(wxListBox* self, wxWindow *parent, wxWindowID id, const wxPoint* pos, const wxSize* size, int n, wxc_string items[], long style, const wxValidator* validator, wxc_string name) { int i; if (pos == NULL) pos = &wxDefaultPosition; if (size == NULL) size = &wxDefaultSize; if (validator == NULL) validator = &wxDefaultValidator; if (name.data==NULL) name = wxc_string("listbox"); wxString* strings = NULL; if (items != NULL) { strings = new wxString[n]; for (i = 0; i < n; ++i) strings[i] = wxstr(items[i]); } return self->Create(parent, id, *pos, *size, n, strings, style, *validator, wxstr(name))?1:0; }
void PaletteWindow::ReloadSettings(Map* map) { if(terrain_palette) { terrain_palette->SetListType(wxstr(settings.getString(Config::PALETTE_TERRAIN_STYLE))); terrain_palette->SetToolbarIconSize(settings.getInteger(Config::USE_LARGE_TERRAIN_TOOLBAR)); } if(doodad_palette) { doodad_palette->SetListType(wxstr(settings.getString(Config::PALETTE_DOODAD_STYLE))); doodad_palette->SetToolbarIconSize(settings.getInteger(Config::USE_LARGE_DOODAD_SIZEBAR)); } if(house_palette) { house_palette->SetMap(map); house_palette->SetToolbarIconSize(settings.getInteger(Config::USE_LARGE_HOUSE_SIZEBAR)); } if(waypoint_palette) { waypoint_palette->SetMap(map); } if(item_palette) { item_palette->SetListType(wxstr(settings.getString(Config::PALETTE_ITEM_STYLE))); item_palette->SetToolbarIconSize(settings.getInteger(Config::USE_LARGE_ITEM_SIZEBAR)); } if(raw_palette) { raw_palette->SetListType(wxstr(settings.getString(Config::PALETTE_RAW_STYLE))); raw_palette->SetToolbarIconSize(settings.getInteger(Config::USE_LARGE_RAW_SIZEBAR)); } InvalidateContents(); }
void HousePalettePanel::SelectTown(size_t index) { ASSERT(town_choice->GetCount() >= index); if(map == nullptr || town_choice->GetCount() == 0) { // No towns :( add_house_button->Enable(false); } else { Town* what_town = reinterpret_cast<Town*>(town_choice->GetClientData(index)); // Clear the old houselist house_list->Clear(); for(HouseMap::iterator house_iter = map->houses.begin(); house_iter != map->houses.end(); ++house_iter) { if(what_town) { if(house_iter->second->townid == what_town->getID()) { house_list->Append(wxstr(house_iter->second->getDescription()), house_iter->second); } } else { // "No Town" selected! if(map->towns.getTown(house_iter->second->townid) == nullptr) { // The town doesn't exist house_list->Append(wxstr(house_iter->second->getDescription()), house_iter->second); } } } // Select first house SelectHouse(0); town_choice->SetSelection(index); add_house_button->Enable(what_town != nullptr); ASSERT(what_town == nullptr || add_house_button->IsEnabled() || !IsEnabled()); } }
extern "C" WXEXPORT wxString* wxFileSelectorEx_func(wxc_string message, wxc_string default_path, wxc_string default_filename, int *indexDefaultExtension, wxc_string wildcard, int flags, wxWindow *parent, int x, int y) { wxString wxmessage, wxwildcard; if (message.data==NULL) wxmessage = wxString(wxFileSelectorPromptStr); else wxmessage = wxstr(message); if (wildcard.data==NULL) wxwildcard = wxString(wxFileSelectorDefaultWildcardStr); else wxwildcard = wxstr(wildcard); return new wxString(wxFileSelectorEx(wxmessage, wxstr(default_path), wxstr(default_filename), indexDefaultExtension, wxwildcard, flags, parent, x, y)); }
void MainFrame::OnUpdateReceived(wxCommandEvent& event) { std::string data = *(std::string*)event.GetClientData(); delete (std::string*)event.GetClientData(); size_t first_colon = data.find(':'); size_t second_colon = data.find(':', first_colon+1); if(first_colon == std::string::npos || second_colon == std::string::npos) return; std::string update = data.substr(0, first_colon); std::string verstr = data.substr(first_colon+1, second_colon-first_colon-1); std::string url = (second_colon == data.size()? "" : data.substr(second_colon+1)); if(update == "yes") { int ret = gui.PopupDialog( wxT("Update Notice"), wxString(wxT("There is a newd update available (")) << wxstr(verstr) << wxT("). Do you want to go to the website and download it?"), wxYES | wxNO, wxT("I don't want any update notices"), Config::AUTOCHECK_FOR_UPDATES ); if(ret == wxID_YES) ::wxLaunchDefaultBrowser(wxstr(url), wxBROWSER_NEW_WINDOW); } }
extern "C" WXEXPORT wxToolBarToolBase* wxToolBar_AddRadioTool(wxToolBar* self, int toolid, wxc_string label, const wxBitmap* bitmap, const wxBitmap* bmpDisabled, wxc_string shortHelp, wxc_string longHelp, wxObject *data) { if (bmpDisabled == NULL) bmpDisabled = &wxNullBitmap; return self->AddRadioTool(toolid, wxstr(label), *bitmap, *bmpDisabled, wxstr(shortHelp), wxstr(longHelp), data); }
extern "C" WXEXPORT wxNumberEntryDialog* wxNumberEntryDialog_ctor(wxWindow* parent, wxc_string message, wxc_string prompt, wxc_string caption, long value, long min, long max, wxPoint* pos) { return new _NumberEntryDialog(parent, wxstr(message), wxstr(prompt), wxstr(caption), value, min, max, *pos); }
extern "C" WXEXPORT long wxGetNumberFromUser_func(wxc_string message, wxc_string prompt, wxc_string caption, long value, long min, long max, wxWindow* parent, wxPoint* pos) { return wxGetNumberFromUser(wxstr(message), wxstr(prompt), wxstr(caption), value, min, max, parent, *pos); }
extern "C" WXEXPORT wxFileDialog* wxFileDialog_ctor(wxWindow* parent, wxc_string message, wxc_string defaultDir, wxc_string defaultFile, wxc_string wildcard, long style, const wxPoint* pos) { return new _FileDialog(parent, wxstr(message), wxstr(defaultDir), wxstr(defaultFile), wxstr(wildcard), style, *pos); }
CreatureType* CreatureType::loadFromXML(pugi::xml_node node, wxArrayString& warnings) { pugi::xml_attribute attribute; if (!(attribute = node.attribute("type"))) { warnings.push_back(wxT("Couldn't read type tag of creature node.")); return nullptr; } const std::string& tmpType = attribute.as_string(); if (tmpType != "monster" && tmpType != "npc") { warnings.push_back(wxT("Invalid type tag of creature node \"") + wxstr(tmpType) + wxT("\"")); return nullptr; } if (!(attribute = node.attribute("name"))) { warnings.push_back(wxT("Couldn't read name tag of creature node.")); return nullptr; } CreatureType* ct = newd CreatureType(); ct->name = attribute.as_string(); ct->isNpc = tmpType == "npc"; if ((attribute = node.attribute("looktype"))) { ct->outfit.lookType = pugi::cast<int32_t>(attribute.value()); if(gui.gfx.getCreatureSprite(ct->outfit.lookType) == nullptr) { warnings.push_back(wxT("Invalid creature \"") + wxstr(ct->name) + wxT("\" look type #") + std::to_string(ct->outfit.lookType)); } } if ((attribute = node.attribute("lookitem"))) { ct->outfit.lookItem = pugi::cast<int32_t>(attribute.value()); } if ((attribute = node.attribute("lookaddon"))) { ct->outfit.lookAddon = pugi::cast<int32_t>(attribute.value()); } if ((attribute = node.attribute("lookhead"))) { ct->outfit.lookHead = pugi::cast<int32_t>(attribute.value()); } if ((attribute = node.attribute("lookbody"))) { ct->outfit.lookBody = pugi::cast<int32_t>(attribute.value()); } if ((attribute = node.attribute("looklegs"))) { ct->outfit.lookLegs = pugi::cast<int32_t>(attribute.value()); } if ((attribute = node.attribute("lookfeet"))) { ct->outfit.lookFeet = pugi::cast<int32_t>(attribute.value()); } return ct; }
// Ask for filename to save extern "C" WXEXPORT wxString* wxSaveFileSelector_func(wxc_string what, wxc_string extension, wxc_string default_name, wxWindow *parent) { return new wxString(wxSaveFileSelector(wxstr(what), wxstr(extension), wxstr(default_name), parent)); }
extern "C" WXEXPORT wxc_bool wxTextCtrl_Create(wxTextCtrl* self, wxWindow *parent, wxWindowID id, wxc_string value, const wxPoint *pos, const wxSize *size, long style, const wxValidator* validator, wxc_string name) { if (pos == NULL) pos = &wxDefaultPosition; if (size == NULL) size = &wxDefaultSize; if (validator == NULL) validator = &wxDefaultValidator; return self->Create(parent, id, wxstr(value), *pos, *size, style, *validator, wxstr(name))?1:0; }
void Application::FixVersionDiscrapencies() { // Here the registry should be fixed, if the version has been changed if(settings.getInteger(Config::VERSION_ID) < MAKE_VERSION_ID(1, 0, 5)) { settings.setInteger(Config::USE_MEMCACHED_SPRITES_TO_SAVE, 0); } if(settings.getInteger(Config::VERSION_ID) < __RME_VERSION_ID__ && ClientVersion::getLatestVersion() != nullptr) { settings.setInteger(Config::DEFAULT_CLIENT_VERSION, ClientVersion::getLatestVersion()->getID()); } wxString ss = wxstr(settings.getString(Config::SCREENSHOT_DIRECTORY)); if(ss.empty()) { ss = wxStandardPaths::Get().GetDocumentsDir(); #ifdef __WINDOWS__ ss += wxT("/My Pictures/RME/"); #endif } settings.setString(Config::SCREENSHOT_DIRECTORY, nstr(ss)); // Set registry to newest version settings.setInteger(Config::VERSION_ID, __RME_VERSION_ID__); }
extern "C" WXEXPORT wxCheckListBox* wxCheckListBox_ctor2(wxWindow* parent, wxWindowID id, const wxPoint* pos, const wxSize* size, int nStrings, wxc_string choices[], long style, const wxValidator* validator, wxc_string name) { if (pos == NULL) pos = &wxDefaultPosition; if (size == NULL) size = &wxDefaultSize; if (validator == NULL) validator = &wxDefaultValidator; if (name.data==NULL) name = wxc_string("checklistbox"); wxString* strings = NULL; if (choices != NULL) { strings = new wxString[nStrings]; for (int i = 0; i < nStrings; ++i) strings[i] = wxstr(choices[i]); } return new _CheckListBox(parent, id, *pos, *size, nStrings, strings, style, *validator, wxstr(name)); }
BrushPalettePanel::BrushPalettePanel(wxWindow* parent, const TilesetContainer& tilesets, TilesetCategoryType category, wxWindowID id) : PalettePanel(parent, id), palette_type(category), choicebook(nullptr), size_panel(nullptr) { wxSizer* topsizer = newd wxBoxSizer(wxVERTICAL); // Create the tileset panel wxSizer* ts_sizer = newd wxStaticBoxSizer(wxVERTICAL, this, wxT("Tileset")); wxChoicebook* tmp_choicebook = newd wxChoicebook(this, wxID_ANY, wxDefaultPosition, wxSize(180,250)); ts_sizer->Add(tmp_choicebook, 1, wxEXPAND); topsizer->Add(ts_sizer, 1, wxEXPAND); for(TilesetContainer::const_iterator iter = tilesets.begin(); iter != tilesets.end(); ++iter) { const TilesetCategory* tcg = iter->second->getCategory(category); if(tcg && tcg->size() > 0) { BrushPanel* panel = newd BrushPanel(tmp_choicebook); panel->AssignTileset(tcg); tmp_choicebook->AddPage(panel, wxstr(iter->second->name)); } } SetSizerAndFit(topsizer); choicebook = tmp_choicebook; }
bool CreatureDatabase::loadFromXML(const FileName& filename, bool standard, wxString& error, wxArrayString& warnings) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file(filename.GetFullPath().mb_str()); if (!result) { error = wxT("Couldn't open file \"") + filename.GetFullName() + wxT("\", invalid format?"); return false; } pugi::xml_node node = doc.child("creatures"); if (!node) { error = wxT("Invalid file signature, this file is not a valid creatures file."); return false; } for (pugi::xml_node creatureNode = node.first_child(); creatureNode; creatureNode = creatureNode.next_sibling()) { if (as_lower_str(creatureNode.name()) != "creature") { continue; } CreatureType* creatureType = CreatureType::loadFromXML(creatureNode, warnings); if (creatureType) { creatureType->standard = standard; if ((*this)[creatureType->name]) { warnings.push_back(wxT("Duplicate creature type name \"") + wxstr(creatureType->name) + wxT("\"! Discarding...")); delete creatureType; } else { creature_map[as_lower_str(creatureType->name)] = creatureType; } } } return true; }
wxString GUI::GetDataDirectory() { std::string cfg_str = g_settings.getString(Config::DATA_DIRECTORY); if(cfg_str.size()) { FileName dir; dir.Assign(wxstr(cfg_str)); wxString path; if(dir.DirExists()) { path = dir.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR); return path; } } // Silently reset directory FileName exec_directory; try { exec_directory = dynamic_cast<wxStandardPaths&>(wxStandardPaths::Get()).GetExecutablePath(); } catch(std::bad_cast) { throw; // Crash application (this should never happend anyways...) } exec_directory.AppendDir(wxT("data")); return exec_directory.GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR); }
void RMENet::OnReceiveDisconnect(NetworkMessage *nmsg) { wxCommandEvent event(EVT_RMENET_CONNECTION_LOST, wxID_ANY); event.SetString(wxstr(nmsg->ReadString())); event.SetInt(1); event_dump->AddPendingEvent(event); }
extern "C" WXEXPORT wxToolBarToolBase* wxToolBar_InsertTool(wxToolBar* self, size_t pos, int toolid, const wxBitmap* bitmap, const wxBitmap* bmpDisabled, wxc_bool toggle, wxObject *clientData, wxc_string shortHelp, wxc_string longHelp) { if (bmpDisabled == NULL) bmpDisabled = &wxNullBitmap; return self->InsertTool(pos, toolid, *bitmap, *bmpDisabled, toggle, clientData, wxstr(shortHelp), wxstr(longHelp)); }
bool Materials::unserializeMaterials(const FileName& filename, xmlNodePtr root, wxString& error, wxArrayString& warnings) { xmlNodePtr materialNode = root->children; wxString warning; while(materialNode) { warning = wxT(""); if(xmlStrcmp(materialNode->name,(const xmlChar*)"include") == 0) { std::string include_file; if(readXMLValue(materialNode, "file", include_file)) { FileName include_name; include_name.SetPath(filename.GetPath()); include_name.SetFullName(wxstr(include_file)); wxString suberror; bool success = loadMaterials(include_name, suberror, warnings); if(!success) warnings.push_back(wxT("Error while loading file \"") + wxstr(include_file) + wxT("\": ") + suberror); } } else if(xmlStrcmp(materialNode->name,(const xmlChar*)"metaitem") == 0) { item_db.loadMetaItem(materialNode); } else if(xmlStrcmp(materialNode->name,(const xmlChar*)"border") == 0) { brushes.unserializeBorder(materialNode, warnings); if(warning.size()) warnings.push_back(wxT("materials.xml: ") + warning); } else if(xmlStrcmp(materialNode->name,(const xmlChar*)"brush") == 0) { brushes.unserializeBrush(materialNode, warnings); if(warning.size()) warnings.push_back(wxT("materials.xml: ") + warning); } else if(xmlStrcmp(materialNode->name,(const xmlChar*)"tileset") == 0) { unserializeTileset(materialNode, warnings); } materialNode = materialNode->next; } return true; }
BrushButton::BrushButton(wxWindow* parent, Brush* _brush, RenderSize sz, uint32_t id) : ItemToggleButton(parent, sz, uint16_t(0), id), brush(_brush) { ASSERT(sz != RENDER_SIZE_64x64); ASSERT(brush); SetSprite(brush->getLookID()); SetToolTip(wxstr(brush->getName())); }
PalettePanel* PaletteWindow::CreateRAWPalette(wxWindow *parent, const TilesetContainer& tilesets) { BrushPalettePanel* panel = newd BrushPalettePanel(parent, tilesets, TILESET_RAW); panel->SetListType(wxstr(settings.getString(Config::PALETTE_RAW_STYLE))); BrushSizePanel* size_panel = newd BrushSizePanel(panel); size_panel->SetToolbarIconSize(settings.getInteger(Config::USE_LARGE_RAW_SIZEBAR)); panel->AddToolPanel(size_panel); return panel; }
extern "C" WXEXPORT wxToolBarToolBase* wxToolBarToolBase_ctor(wxToolBar *tbar, int toolid, wxc_string label, const wxBitmap* bmpNormal, const wxBitmap* bmpDisabled, wxItemKind kind, wxObject *clientData, wxc_string shortHelpString, wxc_string longHelpString) { if (bmpNormal == NULL) bmpNormal = &wxNullBitmap; if (bmpDisabled == NULL) bmpDisabled = &wxNullBitmap; return new wxToolBarToolBase(tbar, toolid, wxstr(label), *bmpNormal, *bmpDisabled, kind, clientData, wxstr(shortHelpString), wxstr(longHelpString)); }
void PropertiesWindow::SetGridValue(wxGrid* grid, int rowIndex, std::string label, const ItemAttribute& attr) { wxArrayString types; types.Add(wxT("Number")); types.Add(wxT("Float")); types.Add(wxT("Boolean")); types.Add(wxT("String")); grid->SetCellValue(label, rowIndex, 0); switch (attr.type) { case ItemAttribute::STRING: { grid->SetCellValue(wxT("String"), rowIndex, 1); grid->SetCellValue(wxstr(*attr.getString()), rowIndex, 2); break; } case ItemAttribute::INTEGER: { grid->SetCellValue(wxT("Number"), rowIndex, 1); grid->SetCellValue(i2ws(*attr.getInteger()), rowIndex, 2); grid->SetCellEditor(rowIndex, 2, new wxGridCellNumberEditor); break; } case ItemAttribute::DOUBLE: case ItemAttribute::FLOAT: { grid->SetCellValue(wxT("Float"), rowIndex, 1); wxString f; f << *attr.getFloat(); grid->SetCellValue(f, rowIndex, 2); grid->SetCellEditor(rowIndex, 2, new wxGridCellFloatEditor); break; } case ItemAttribute::BOOLEAN: { grid->SetCellValue(wxT("Boolean"), rowIndex, 1); grid->SetCellValue(*attr.getBoolean() ? wxT("1") : wxT(""), rowIndex, 2); grid->SetCellRenderer(rowIndex, 2, new wxGridCellBoolRenderer); grid->SetCellEditor(rowIndex, 2, new wxGridCellBoolEditor); break; } default: { grid->SetCellValue(wxT("Unknown"), rowIndex, 1); grid->SetCellBackgroundColour(*wxLIGHT_GREY, rowIndex, 1); grid->SetCellBackgroundColour(*wxLIGHT_GREY, rowIndex, 2); grid->SetReadOnly(rowIndex, 1, true); grid->SetReadOnly(rowIndex, 2, true); break; } } grid->SetCellEditor(rowIndex, 1, new wxGridCellChoiceEditor(types)); }
extern "C" WXEXPORT void wxListBox_InsertItems(wxListBox* self, int nItems, wxc_string items[], int pos) { int i; wxString* strings = new wxString[nItems]; for (i = 0; i < nItems; ++i) strings[i] = wxstr(items[i]); self->InsertItems(nItems, strings, pos); }
extern "C" WXEXPORT void wxListBox_Set(wxListBox* self, int n, wxc_string items[], void *clientData) { int i; wxString* strings = new wxString[n]; for (i = 0; i < n; ++i) strings[i] = wxstr(items[i]); self->Set(n, strings, &clientData); }
void CopyBuffer::copy(Editor& editor, int floor) { if(editor.selection.size() == 0) { gui.SetStatusText(wxT("No tiles to copy.")); return; } clear(); tiles = newd BaseMap(); int tile_count = 0; int item_count = 0; copyPos = Position(0xFFFF, 0xFFFF, floor); for(TileVector::iterator it = editor.selection.begin(); it != editor.selection.end(); ++it) { ++tile_count; Tile* tile = *it; TileLocation* newlocation = tiles->createTileL(tile->getPosition()); Tile* copied_tile = tiles->allocator(newlocation); if(tile->ground && tile->ground->isSelected()) { copied_tile->house_id = tile->house_id; copied_tile->setMapFlags(tile->getMapFlags()); } ItemVector tile_selection = tile->getSelectedItems(); for(ItemVector::iterator iit = tile_selection.begin(); iit != tile_selection.end(); ++iit) { ++item_count; // Copy items to copybuffer copied_tile->addItem((*iit)->deepCopy()); } if(tile->creature && tile->creature->isSelected()) { copied_tile->creature = tile->creature->deepCopy(); } if(tile->spawn && tile->spawn->isSelected()) { copied_tile->spawn = tile->spawn->deepCopy(); } tiles->setTile(copied_tile); if(copied_tile->getX() < copyPos.x) copyPos.x = copied_tile->getX(); if(copied_tile->getY() < copyPos.y) copyPos.y = copied_tile->getY(); } std::ostringstream ss; ss << "Copied " << tile_count << " tile" << (tile_count > 1 ? "s" : "") << " (" << item_count << " item" << (item_count > 1? "s" : "") << ")"; gui.SetStatusText(wxstr(ss.str())); }
void HousePalettePanel::OnClickAddHouse(wxCommandEvent& event) { if(map == nullptr) return; House* new_house = newd House(*map); new_house->id = map->houses.getEmptyID(); std::ostringstream os; os << "Unnamed House #" << new_house->id; new_house->name = os.str(); Town* town = reinterpret_cast<Town*>(town_choice->GetClientData(town_choice->GetSelection())); ASSERT(town); new_house->townid = town->getID(); map->houses.addHouse(new_house); house_list->Append(wxstr(new_house->getDescription()), new_house); SelectHouse(house_list->FindString(wxstr(new_house->getDescription()))); gui.SelectBrush(); refresh_timer.Start(300, true); }
PalettePanel* PaletteWindow::CreateDoodadPalette(wxWindow *parent, const TilesetContainer& tilesets) { BrushPalettePanel* panel = newd BrushPalettePanel(parent, tilesets, TILESET_DOODAD); panel->SetListType(wxstr(g_settings.getString(Config::PALETTE_DOODAD_STYLE))); panel->AddToolPanel(newd BrushThicknessPanel(panel)); BrushSizePanel* size_panel = newd BrushSizePanel(panel); size_panel->SetToolbarIconSize(g_settings.getBoolean(Config::USE_LARGE_DOODAD_SIZEBAR)); panel->AddToolPanel(size_panel); return panel; }