/*********************************************************************************** ** GetItemData ** ** ***********************************************************************************/ OP_STATUS SearchTemplate::GetItemData(ItemData* item_data) { if (item_data->query_type == COLUMN_QUERY) { switch(item_data->column_query_data.column) { case 0: { if (item_data->flags & FLAG_NO_PAINT) break; item_data->column_bitmap = GetIcon(); if (item_data->column_bitmap.IsEmpty()) { item_data->column_query_data.column_image = "Search Web"; } break; } case 1: { RETURN_IF_ERROR(GetEngineName(*item_data->column_query_data.column_text)); break; } case 2: { RETURN_IF_ERROR(item_data->column_query_data.column_text->Set(m_key)); break; } } } return OpStatus::OK; }
// Fill list of game titles made with selected engine void UIStartupDialog::FillGameList() { OverrideGameCombo->RemoveAllItems(); const char* selectedEngine = OverrideEngineCombo->GetSelectionText(); TArray<const char*> gameNames; int numEngineEntries = 0; int i; for (i = 0; /* empty */; i++) { const GameInfo &info = GListOfGames[i]; if (!info.Name) break; const char* engine = GetEngineName(info.Enum); if (!strcmp(engine, selectedEngine)) { gameNames.Add(info.Name); if (!strnicmp(info.Name, "Unreal engine ", 14)) numEngineEntries++; } } if (gameNames.Num() > numEngineEntries + 1) { // sort items, keep 1st numEngineEntries items (engine name) in place QSort(&gameNames[numEngineEntries], gameNames.Num() - numEngineEntries, CompareStrings); } for (i = 0; i < gameNames.Num(); i++) OverrideGameCombo->AddItem(gameNames[i]); // select engine item OverrideGameCombo->SelectItem(0); }
void PrintGameList(bool tags) { const char *oldTitle = NULL; int pos = 0; #define LINEFEED 80 int Count = ARRAY_COUNT(GListOfGames) - 1; // exclude TABLE_END marker bool out = false; for (int i = 0; i < Count; i++) { const GameInfo &info = GListOfGames[i]; if (tags && !info.Switch) continue; // engine title const char *title = GetEngineName(info.Enum); if (title != oldTitle) { appPrintf("%s%s:", out ? "\n\n" : "", title); pos = LINEFEED; } oldTitle = title; out = true; // game info if (tags) { appPrintf("\n %8s %s", info.Switch ? info.Switch : "", info.Name); continue; } // simple game list if (!(info.Enum & ~GAME_ENGINE) && info.Switch) continue; // skip simple GAME_UEn const char *name = info.Name; int len = strlen(name); bool needComma = (i < Count - 1) && (GetEngineName(GListOfGames[i+1].Enum) == title); if (needComma) len += 2; if (pos >= LINEFEED - len) { appPrintf("\n "); pos = 2; } appPrintf("%s%s", name, needComma ? ", " : ""); pos += len; } appPrintf("\n"); }
/**\brief Save this Player to an xml node */ xmlNodePtr Player::ToXMLNode(string componentName) { char buff[256]; char *timestamp; xmlNodePtr section = xmlNewNode(NULL, BAD_CAST componentName.c_str()); // Version information snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MAJOR); xmlNewChild(section, NULL, BAD_CAST "version-major", BAD_CAST buff); snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MINOR); xmlNewChild(section, NULL, BAD_CAST "version-minor", BAD_CAST buff); snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MICRO); xmlNewChild(section, NULL, BAD_CAST "version-macro", BAD_CAST buff); // Player Stats xmlNewChild(section, NULL, BAD_CAST "name", BAD_CAST GetName().c_str() ); xmlNodePtr planet = xmlNewNode(NULL, BAD_CAST "planet" ); xmlNewChild(planet, NULL, BAD_CAST "name", BAD_CAST lastPlanet.c_str()); snprintf(buff, sizeof(buff), "%d", (int)GetWorldPosition().GetX() ); xmlNewChild(planet, NULL, BAD_CAST "x", BAD_CAST buff ); snprintf(buff, sizeof(buff), "%d", (int)GetWorldPosition().GetY() ); xmlNewChild(planet, NULL, BAD_CAST "y", BAD_CAST buff ); xmlAddChild(section,planet); xmlNewChild(section, NULL, BAD_CAST "model", BAD_CAST GetModelName().c_str() ); xmlNewChild(section, NULL, BAD_CAST "engine", BAD_CAST GetEngineName().c_str() ); snprintf(buff, sizeof(buff), "%d", this->GetCredits() ); xmlNewChild(section, NULL, BAD_CAST "credits", BAD_CAST buff ); // this part is becoming less important and may be removed at some point for(unsigned int i = 0; i < weaponSlots.size(); i++){ xmlNewChild(section, NULL, BAD_CAST "weapon", BAD_CAST GetWeaponSlotContent(i).c_str() ); } // Ammo for(int a=0;a<max_ammo;a++){ if(GetAmmo(AmmoType(a)) != 0 ){ // Don't save empty ammo Nodes snprintf(buff, sizeof(buff), "%d", GetAmmo(AmmoType(a)) ); xmlNodePtr ammo = xmlNewNode(NULL, BAD_CAST "ammo"); xmlNewChild(ammo, NULL, BAD_CAST "type", BAD_CAST Weapon::AmmoTypeToName((AmmoType)a).c_str() ); xmlNewChild(ammo, NULL, BAD_CAST "amount", BAD_CAST buff ); xmlAddChild(section, ammo); } } // Weapon Slots // save info about whichever items players are able to change in their slot configuration (content and firing group) for(unsigned int w=0; w < weaponSlots.size(); w++){ WeaponSlot *slot = &weaponSlots[w]; xmlNodePtr slotPtr = xmlNewNode(NULL, BAD_CAST "weapSlot"); xmlNewChild(slotPtr, NULL, BAD_CAST "name", BAD_CAST GetWeaponSlotName(w).c_str() ); xmlNewChild(slotPtr, NULL, BAD_CAST "content", BAD_CAST GetWeaponSlotContent(w).c_str() ); snprintf(buff, sizeof(buff), "%d", slot->firingGroup); xmlNewChild(slotPtr, NULL, BAD_CAST "firingGroup", BAD_CAST buff); xmlAddChild(section, slotPtr); // saved player data is less structured than model data, so just add it here } // Cargo map<Commodity*,unsigned int> cargo = this->GetCargo(); map<Commodity*,unsigned int>::iterator iter_com; for(iter_com = cargo.begin(); iter_com!=cargo.end(); ++iter_com) { if( !(*iter_com).second ) { continue; // Don't Save empty cargo Nodes } snprintf(buff, sizeof(buff), "%d", (*iter_com).second ); xmlNodePtr ammo = xmlNewNode(NULL, BAD_CAST "cargo"); xmlNewChild(ammo, NULL, BAD_CAST "type", BAD_CAST ((*iter_com).first)->GetName().c_str() ); xmlNewChild(ammo, NULL, BAD_CAST "amount", BAD_CAST buff ); xmlAddChild(section, ammo); } // Outfit list<Outfit*> *outfits = this->GetOutfits(); for( list<Outfit*>::iterator it_w = outfits->begin(); it_w!=outfits->end(); ++it_w ){ xmlNewChild(section, NULL, BAD_CAST "outfit", BAD_CAST (*it_w)->GetName().c_str() ); } // Missions list<Mission*>::iterator iter_mission; for(iter_mission = missions.begin(); iter_mission != missions.end(); ++iter_mission){ xmlAddChild( section, (*iter_mission)->ToXMLNode() ); } // Favor map<Alliance*,int>::iterator iter_favor; for(iter_favor = favor.begin(); iter_favor!=favor.end(); ++iter_favor) { if( !(*iter_favor).second ) { continue; // Don't Save empty favor Nodes } snprintf(buff, sizeof(buff), "%d", (*iter_favor).second ); xmlNodePtr ammo = xmlNewNode(NULL, BAD_CAST "favor"); xmlNewChild(ammo, NULL, BAD_CAST "alliance", BAD_CAST ((*iter_favor).first)->GetName().c_str() ); xmlNewChild(ammo, NULL, BAD_CAST "value", BAD_CAST buff ); xmlAddChild(section, ammo); } // Hired escorts for(list<HiredEscort*>::iterator iter_escort = hiredEscorts.begin(); iter_escort != hiredEscorts.end(); iter_escort++){ // Check that the sprite hasn't already been destroyed. (If it has, leave it out.) ///\todo We should remove the SpriteManager reference here to remove a dependency on global variables. if( (*iter_escort)->spriteID != -1 && SpriteManager::Instance()->GetSpriteByID( (*iter_escort)->spriteID ) != NULL ){ xmlNodePtr hePtr = xmlNewNode(NULL, BAD_CAST "hiredEscort"); xmlNewChild(hePtr, NULL, BAD_CAST "type", BAD_CAST (*iter_escort)->type.c_str() ); snprintf(buff, sizeof(buff), "%d", (*iter_escort)->pay); xmlNewChild(hePtr, NULL, BAD_CAST "pay", BAD_CAST buff); xmlAddChild(section, hePtr); // Don't include spriteID in the XML file, for obvious reasons. } } // Last Load Time snprintf(buff, sizeof(buff), "%d", (int)lastLoadTime ); xmlNewChild(section, NULL, BAD_CAST "lastLoadTime", BAD_CAST buff ); // Save a Human readable comment to explain the Last Load time strcpy( buff, "Last Load: " ); timestamp = ctime( &lastLoadTime ); timestamp[strlen(timestamp)-1] = '\0'; xmlAddChild( section, xmlNewComment( BAD_CAST timestamp)); return section; }
void UIStartupDialog::InitUI() { guard(UIStartupDialog::InitUI); (*this) [ NewControl(UILabel, "Path to game files:") + NewControl(UIFilePathEditor, &Opt.GamePath) //!! could check file extensions in target directory and at least //!! set "engine" part of "game override", if it is not set yet ]; NewControl(UICheckboxGroup, "Override game detection", Opt.GameOverride != GAME_UNKNOWN) .SetParent(this) .Expose(OverrideGameGroup) [ NewControl(UIGroup, GROUP_HORIZONTAL_LAYOUT|GROUP_NO_BORDER) [ NewControl(UICombobox) .Expose(OverrideEngineCombo) .SetCallback(BIND_MEM_CB(&UIStartupDialog::FillGameList, this)) .SetWidth(EncodeWidth(0.4f)) + NewControl(UISpacer) + NewControl(UICombobox) .Expose(OverrideGameCombo) ] ]; // fill engines list int i; const char* lastEngine = NULL; const GameInfo* selectedGame = NULL; for (i = 0; /* empty */; i++) { const GameInfo &info = GListOfGames[i]; if (!info.Name) break; if (info.Enum == Opt.GameOverride) selectedGame = &info; const char* engine = GetEngineName(info.Enum); if (engine != lastEngine) { lastEngine = engine; OverrideEngineCombo->AddItem(engine); } } // select a game passed through the command line if (selectedGame) { OverrideEngineCombo->SelectItem(GetEngineName(selectedGame->Enum)); FillGameList(); OverrideGameCombo->SelectItem(selectedGame->Name); } #if 0 OverrideEngineCombo->SelectItem("Unreal engine 3"); // this engine has most number of game titles FillGameList(); #endif NewControl(UIGroup, "Engine classes to load", GROUP_HORIZONTAL_LAYOUT) .SetParent(this) [ NewControl(UIGroup, GROUP_NO_BORDER) [ NewControl(UILabel, "Common classes:") + NewControl(UICheckbox, "Skeletal mesh", &Opt.UseSkeletalMesh) + NewControl(UICheckbox, "Static mesh", &Opt.UseStaticMesh) + NewControl(UICheckbox, "Animation", &Opt.UseAnimation) + NewControl(UICheckbox, "Textures", &Opt.UseTexture) + NewControl(UICheckbox, "Lightmaps", &Opt.UseLightmapTexture) ] + NewControl(UIGroup, GROUP_NO_BORDER) [ NewControl(UILabel, "Export-only classes:") + NewControl(UICheckbox, "Sound", &Opt.UseSound) + NewControl(UICheckbox, "ScaleForm", &Opt.UseScaleForm) + NewControl(UICheckbox, "FaceFX", &Opt.UseFaceFx) ] ]; (*this) [ NewControl(UIGroup, GROUP_HORIZONTAL_LAYOUT|GROUP_NO_BORDER) [ NewControl(UIGroup, "Package compression", GROUP_HORIZONTAL_LAYOUT|GROUP_HORIZONTAL_SPACING) .SetWidth(EncodeWidth(0.35f)) .SetRadioVariable(&Opt.PackageCompression) [ NewControl(UIRadioButton, "Auto", 0) + NewControl(UIRadioButton, "LZO", COMPRESS_LZO) + NewControl(UIRadioButton, "zlib", COMPRESS_ZLIB) + NewControl(UIRadioButton, "LZX", COMPRESS_LZX) ] + NewControl(UISpacer) + NewControl(UIGroup, "Platform", GROUP_HORIZONTAL_LAYOUT|GROUP_HORIZONTAL_SPACING) .SetRadioVariable(&Opt.Platform) [ NewControl(UIRadioButton, "Auto", PLATFORM_UNKNOWN) + NewControl(UIRadioButton, "PC", PLATFORM_PC) + NewControl(UIRadioButton, "XBox360", PLATFORM_XBOX360) + NewControl(UIRadioButton, "PS3", PLATFORM_PS3) + NewControl(UIRadioButton, "iOS", PLATFORM_IOS) + NewControl(UIRadioButton, "Android", PLATFORM_ANDROID) ] ] ]; // dialog buttons NewControl(UIGroup, GROUP_HORIZONTAL_LAYOUT|GROUP_NO_BORDER) .SetParent(this) [ NewControl(UISpacer, -1) + NewControl(UIButton, "OK") .SetWidth(EncodeWidth(0.2f)) .SetOK() + NewControl(UISpacer) + NewControl(UIButton, "Cancel") .SetWidth(EncodeWidth(0.2f)) .SetCancel() ]; //!! - possibility to select a file to open, setup game path from it, //!! set file mask from known file extensions //!! - save log to file (-log=...) //!! - about/help unguard; }