/** ** Pre menu setup. */ void PreMenuSetup() { // // Initial menus require some gfx. // SetDefaultTextColors(FontYellow, FontWhite); LoadFonts(); InitVideoCursors(); if (MenuRace.empty()) { //Wyrmgus start // LoadCursors(PlayerRaces.Name[0]); LoadCursors(); //Wyrmgus end } else { //Wyrmgus start // LoadCursors(MenuRace); LoadCursors(); //Wyrmgus end } InitSettings(); InitUserInterface(); UI.Load(); }
/** ** Load all. ** ** Call each module to load additional files (graphics,sounds). */ void LoadModules() { LoadFonts(); LoadIcons(); LoadCursors(PlayerRaces.Name[ThisPlayer->Race]); UI.Load(); #ifndef DYNAMIC_LOAD LoadMissileSprites(); #endif LoadConstructions(); LoadDecorations(); LoadUnitTypes(); InitPathfinder(); LoadUnitSounds(); MapUnitSounds(); if (SoundEnabled()) { InitSoundClient(); } SetPlayersPalette(); UI.Minimap.Create(); SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor); }
CMouseHandler::CMouseHandler() : lastx(-1) , lasty(-1) , locked(false) , doubleClickTime(0.0f) , scrollWheelSpeed(0.0f) , activeButton(-1) , dir(ZeroVector) , wasLocked(false) , crossSize(0.0f) , crossAlpha(0.0f) , crossMoveScale(0.0f) , cursorText("") , currentCursor(NULL) , cursorScale(1.0f) , hide(true) , hwHide(true) , hardwareCursor(false) , invertMouse(false) , dragScrollThreshold(0.0f) , scrollx(0.0f) , scrolly(0.0f) { const int2 mousepos = IMouseInput::GetInstance()->GetPos(); lastx = mousepos.x; lasty = mousepos.y; for (int a = 1; a <= NUM_BUTTONS; a++) { buttons[a].pressed = false; buttons[a].lastRelease = -20; buttons[a].movement = 0; } LoadCursors(); currentCursor = cursorCommandMap[""]; #ifndef __APPLE__ hardwareCursor = configHandler->GetBool("HardwareCursor"); #endif invertMouse = configHandler->GetBool("InvertMouse"); doubleClickTime = configHandler->GetFloat("DoubleClickTime") / 1000.0f; scrollWheelSpeed = configHandler->GetFloat("ScrollWheelSpeed"); crossSize = configHandler->GetFloat("CrossSize"); crossAlpha = configHandler->GetFloat("CrossAlpha"); crossMoveScale = configHandler->GetFloat("CrossMoveScale") * 0.005f; dragScrollThreshold = configHandler->GetFloat("MouseDragScrollThreshold"); configHandler->NotifyOnChange(this); }
CMouseHandler::CMouseHandler() : hardwareCursor(false) , lastx(300) , lasty(200) , hide(true) , hwHide(true) , locked(false) , invertMouse(false) , doubleClickTime(0.0f) , scrollWheelSpeed(0.0f) , dragScrollThreshold(0.0f) , crossSize(0.0f) , crossAlpha(0.0f) , crossMoveScale(0.0f) , activeButton(-1) , dir(ZeroVector) , soundMultiselID(0) , cursorScale(1.0f) , cursorText("") , currentCursor(NULL) , wasLocked(false) , scrollx(0.0f) , scrolly(0.0f) { for (int a = 1; a <= NUM_BUTTONS; a++) { buttons[a].pressed = false; buttons[a].lastRelease = -20; buttons[a].movement = 0; } LoadCursors(); #ifndef __APPLE__ hardwareCursor = !!configHandler->Get("HardwareCursor", 0); #endif soundMultiselID = sound->GetSoundId("MultiSelect", false); invertMouse = !!configHandler->Get("InvertMouse",0); doubleClickTime = configHandler->Get("DoubleClickTime", 200.0f) / 1000.0f; scrollWheelSpeed = configHandler->Get("ScrollWheelSpeed", 25.0f); scrollWheelSpeed = Clamp(scrollWheelSpeed,-255.f,255.f); crossSize = configHandler->Get("CrossSize", 12.0f); crossAlpha = configHandler->Get("CrossAlpha", 0.5f); crossMoveScale = configHandler->Get("CrossMoveScale", 1.0f) * 0.005f; dragScrollThreshold = configHandler->Get("MouseDragScrollThreshold", 0.3f); configHandler->NotifyOnChange(this); }
CMouseHandler::CMouseHandler() : locked(false) { lastx = 300; lasty = 200; hide = true; hwHide = true; currentCursor = NULL; for (int a = 1; a <= NUM_BUTTONS; a++) { buttons[a].pressed = false; buttons[a].lastRelease = -20; buttons[a].movement = 0; } cursorScale = 1.0f; LoadCursors(); // hide the cursor until we are ingame (not in loading screen etc.) SDL_ShowCursor(SDL_DISABLE); #ifdef __APPLE__ hardwareCursor = false; #else hardwareCursor = !!configHandler->Get("HardwareCursor", 0); #endif soundMultiselID = sound->GetSoundId("MultiSelect", false); invertMouse = !!configHandler->Get("InvertMouse",0); doubleClickTime = configHandler->Get("DoubleClickTime", 200.0f) / 1000.0f; scrollWheelSpeed = configHandler->Get("ScrollWheelSpeed", 25.0f); scrollWheelSpeed = std::max(-255.0f, std::min(255.0f, scrollWheelSpeed)); }
//////////////////////////////////////////////////////////////////////////////// // Loads and processes the skin description file which is in fact a regular // Allegro configuration file MAS::Error MAS::Skin::Load(const char *file) { int i = 0; lastError = MAS::Error(MAS::Error::NONE); ALLEGRO_CONFIG *config; const char *str; ALLEGRO_PATH *sdp; if (!file) { lastError = MAS::Error(MAS::Error::SKIN_INI); return lastError; } // Try to open the skin description file sdp = al_create_path(file); if (!al_is_path_present(sdp)) { al_destroy_path(sdp); lastError = MAS::Error(MAS::Error::SKIN_INI); return lastError; } config = al_load_config_file(file); if (skinFilePath != file) { delete [] skinFilePath; skinFilePath = new char[1+strlen(file)]; strcpy(skinFilePath, file); } Reset(); // Get the path to the skin configuration file (drop the filename) al_set_path_filename(sdp, ""); //////////////////////////////////////////////////////////////////////////////// // Read the name of the dir and load the bitmap data bool default_bitmaps = false; str = al_get_config_value(config, "Skin", "main_data"); if (str) { al_append_path_component(sdp, str); lastError = LoadData(sdp, config); al_drop_path_tail(sdp); if (lastError) { al_destroy_config(config); al_destroy_path(sdp); delete [] skinFilePath; skinFilePath = NULL; return lastError; } } else { default_bitmaps = true; } //////////////////////////////////////////////////////////////////////////////// // Read the default colors #define GET_COLOR_STR(val, def) ((str = al_get_config_value(config, "COLORS", val)) ? str : def) c_face = MAS::Color(GET_COLOR_STR("face", "210,210,210")); c_font = MAS::Color(GET_COLOR_STR("fontface", " 16, 16, 16")); c_shad1 = MAS::Color(GET_COLOR_STR("shad1", "255,255,255")); c_shad2 = MAS::Color(GET_COLOR_STR("shad2", " 80, 80, 80")); c_disable = MAS::Color(GET_COLOR_STR("disable", "128,128,128")); c_select = MAS::Color(GET_COLOR_STR("select", "128,192,128")); c_deselect = MAS::Color(GET_COLOR_STR("deselect", "224,224,224")); c_focus = MAS::Color(GET_COLOR_STR("focus", "128,192,128")); c_sunken = MAS::Color(GET_COLOR_STR("sunken", "232,232,232")); c_back = MAS::Color(GET_COLOR_STR("back", "180,180,180")); #undef GET_COLOR_STR if (default_bitmaps) { GenerateDefaultBitmaps(); } //////////////////////////////////////////////////////////////////////////////// // Read the cursors from another datafile str = al_get_config_value(config, "Skin", "cursors"); if (str) { al_append_path_component(sdp, str); lastError = LoadCursors(sdp, config); al_drop_path_tail(sdp); if (lastError) { al_destroy_config(config); al_destroy_path(sdp); delete [] skinFilePath; skinFilePath = NULL; return lastError; } } //////////////////////////////////////////////////////////////////////////////// // Read the samples from another datafile str = al_get_config_value(config, "Skin", "sounds"); if (str) { al_append_path_component(sdp, str); lastError = LoadSamples(sdp); al_drop_path_tail(sdp); if (lastError) { al_destroy_config(config); al_destroy_path(sdp); delete [] skinFilePath; skinFilePath = NULL; return lastError; } } #define GET_CONFIG_STR(section, key, def) \ (str = al_get_config_value(config, section, key)) ? strtol(str, NULL, 10) : def //////////////////////////////////////////////////////////////////////////////// // Now load the fonts const char *fonts[] = { "FONT0", "FONT1", "FONT2", "FONT3", "FONT4", "FONT5", "FONT6", "FONT7" }; const char *ttfont; int size; for (i=0; i<nFonts; i++) { size = GET_CONFIG_STR(fonts[i], "size", 10); ttfont = al_get_config_value(config, fonts[i], "file"); // the filename of the font al_set_path_filename(sdp, ttfont); const char *filename = al_path_cstr(sdp, ALLEGRO_NATIVE_PATH_SEP); fntList[i]->Load(filename, size, false); } //////////////////////////////////////////////////////////////////////////////// // Read the object specific data: //---------------------------------------------- const char *fnames[] = { "font1", "font2", "font3", "font4" }; const char *cnames[] = { "f_col1", "f_col2", "f_col3", "f_col4" }; const char *snames[] = { "s_col1", "s_col2", "s_col3", "s_col4" }; const char *def_col[] = { "0,0,0", "0,0,0", "128,128,128", "0,0,0" }; const char *def_shd[] = { "-1", "-1", "-1", "-1" }; // button, checkbox, radio button, etc. const char *info_name[] = { "BOX", "BUTTON", "CHECKBOX", "RADIO", "LIST", "WINDOW", "MENU", "TEXT", "EDITBOX", "PROGRESS", "HYPER", "TAB", "TOOLTIP" }; for (int j=0; j<nInfoItems; j++) { for (i=0; i<4; i++) { fnt[j][i] = GET_CONFIG_STR(info_name[i], fnames[i], 10); fcol[j][i] = Color((str = al_get_config_value(config, info_name[j], cnames[i])) ? str : def_col[i]); scol[j][i] = Color((str = al_get_config_value(config, info_name[j], snames[i])) ? str : def_shd[i]); } } // wallpaper style wallpaperStyle = GET_CONFIG_STR("WALLPAPER", "style", 3); // buttons animation buttonDisplacement = GET_CONFIG_STR("BUTTON", "displacement", 1); buttonAnimationType = GET_CONFIG_STR("BUTTON", "animationType", 0); buttonAnimationLength = GET_CONFIG_STR("BUTTON", "animationLength", 0); // group box info boxX = GET_CONFIG_STR("BOX", "offX", 6); boxY = GET_CONFIG_STR("BOX", "offY", 1); boxAlign = GET_CONFIG_STR("BOX", "alignment", 0); boxBack = (str = al_get_config_value(config, "BOX", "backColor")) ? str : "222,222,222"; // window winTextPos.x( GET_CONFIG_STR("WINDOW", "textX", 10)); winTextPos.y( GET_CONFIG_STR("WINDOW", "textY", 18)); winTextAlign = GET_CONFIG_STR("WINDOW", "alignment", 0); winTextBack = GET_CONFIG_STR("WINDOW", "textBack", 0); winExitPos.x( GET_CONFIG_STR("WINDOW", "exitX", -22)); winExitPos.y( GET_CONFIG_STR("WINDOW", "exitY", 6)); winMaxPos.x( GET_CONFIG_STR("WINDOW", "manX", -40)); winMaxPos.y( GET_CONFIG_STR("WINDOW", "manY", 6)); winMinPos.x( GET_CONFIG_STR("WINDOW", "minX", -56)); winMinPos.y( GET_CONFIG_STR("WINDOW", "minY", 6)); winAnimationType = GET_CONFIG_STR("WINDOW", "animationType", 0); winAnimationLength = GET_CONFIG_STR("WINDOW", "animationLength", 0); // combo box comboAnimationType = GET_CONFIG_STR("COMBOBOX", "animationType", 0); comboAnimationLength = GET_CONFIG_STR("COMBOBOX", "animationLength", 0); // menu menuHeight = GET_CONFIG_STR("MENU", "height", 16); menuDelay = GET_CONFIG_STR("MENU", "delay", 300); menuAnimationType = GET_CONFIG_STR("MENU", "animationType", 0); menuAnimationLength = GET_CONFIG_STR("MENU", "animationLength", 0); // tooltip info tooltipAnimationType = GET_CONFIG_STR("TOOLTIP", "animationType", 0); tooltipAnimationLength = GET_CONFIG_STR("TOOLTIP", "animationLength", 0); tooltipBack = Color((str = al_get_config_value(config, "TOOLTIP", "backColor")) ? str : "255,255,192"); tooltipBorder = Color((str = al_get_config_value(config, "TOOLTIP", "backColor")) ? str : "0,0,0"); // dialog popup animation // ... // should the GUI draw dotted rectangles? drawDots = (str = al_get_config_value(config, "Skin", "dottedRect")) ? *str != '0' : false; // how the focus follows the mouse focus = GET_CONFIG_STR("Skin", "focus", 1); #undef GET_CONFIG_STR al_destroy_path(sdp); return MAS::Error(MAS::Error::NONE); }
/** ** CreateGame. ** ** Load map, graphics, sounds, etc ** ** @param filename map filename ** @param map map loaded ** ** @todo FIXME: use in this function InitModules / LoadModules!!! */ void CreateGame(const char *filename, CMap *map) { int i; if (SaveGameLoading) { SaveGameLoading = 0; // Load game, already created game with Init/LoadModules CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1); return; } InitVisionTable(); // build vision table for fog of war InitPlayers(); if (Map.Info.Filename.empty() && filename) { char path[PATH_MAX]; Assert(filename); LibraryFileName(filename, path, sizeof(path)); if(strcasestr(filename, ".smp")) { LuaLoadFile(path); } } for (i = 0; i < PlayerMax; ++i) { int playertype = Map.Info.PlayerType[i]; // Network games only: if (GameSettings.Presets[i].Type != SettingsPresetMapDefault) { playertype = GameSettings.Presets[i].Type; } CreatePlayer(playertype); } if (filename) { if (CurrentMapPath != filename) { strcpy_s(CurrentMapPath, sizeof(CurrentMapPath), filename); } // // Load the map. // InitUnitTypes(1); LoadMap(filename, map); // HARDCODING FOG OF WAR TRUE. It doesn't currently use preferences on a game restart - Should be changed map->NoFogOfWar = true; Map.Reveal(); } GameCycle = 0; FastForwardCycle = 0; SyncHash = 0; InitSyncRand(); if (IsNetworkGame()) { // Prepare network play DebugPrint("Client setup: Calling InitNetwork2\n"); InitNetwork2(); } else { if (LocalPlayerName && strcmp(LocalPlayerName, "Anonymous")) { ThisPlayer->SetName(LocalPlayerName); } } CallbackMusicOn(); #if 0 GamePaused = true; #endif if (FlagRevealMap) { Map.Reveal(); } // // Setup game types // // FIXME: implement more game types if (GameSettings.GameType != SettingsGameTypeMapDefault) { switch (GameSettings.GameType) { case SettingsGameTypeMelee: break; case SettingsGameTypeFreeForAll: GameTypeFreeForAll(); break; case SettingsGameTypeTopVsBottom: GameTypeTopVsBottom(); break; case SettingsGameTypeLeftVsRight: GameTypeLeftVsRight(); break; case SettingsGameTypeManVsMachine: GameTypeManVsMachine(); break; case SettingsGameTypeManTeamVsMachine: GameTypeManTeamVsMachine(); // Future game type ideas #if 0 case SettingsGameTypeOneOnOne: break; case SettingsGameTypeCaptureTheFlag: break; case SettingsGameTypeGreed: break; case SettingsGameTypeSlaughter: break; case SettingsGameTypeSuddenDeath: break; case SettingsGameTypeTeamMelee: break; case SettingsGameTypeTeamCaptureTheFlag: break; #endif } } // // Graphic part // SetPlayersPalette(); InitIcons(); LoadIcons(); LoadCursors(PlayerRaces.Name[ThisPlayer->Race]); UnitUnderCursor = NoUnitP; InitMissileTypes(); #ifndef DYNAMIC_LOAD LoadMissileSprites(); #endif InitConstructions(); LoadConstructions(); LoadUnitTypes(); LoadDecorations(); InitSelections(); InitUserInterface(); UI.Load(); UI.Minimap.Create(); Map.Init(); PreprocessMap(); // // Sound part // LoadUnitSounds(); MapUnitSounds(); if (SoundEnabled()) { InitSoundClient(); } // // Spells // InitSpells(); // // Init units' groups // InitGroups(); // // Init players? // DebugPlayers(); PlayersInitAi(); // // Upgrades // InitUpgrades(); // // Dependencies // InitDependencies(); // // Buttons (botpanel) // InitButtons(); // // Triggers // InitTriggers(); SetDefaultTextColors(UI.NormalFontColor, UI.ReverseFontColor); #if 0 if (!UI.SelectedViewport) { UI.SelectedViewport = UI.Viewports; } #endif UI.SelectedViewport->Center( ThisPlayer->StartX, ThisPlayer->StartY, TileSizeX / 2, TileSizeY / 2); // // Various hacks wich must be done after the map is loaded. // // FIXME: must be done after map is loaded InitAStar(); // // FIXME: The palette is loaded after the units are created. // FIXME: This loops fixes the colors of the units. // for (i = 0; i < NumUnits; ++i) { // I don't really think that there can be any rescued // units at this point. if (Units[i]->RescuedFrom) { Units[i]->Colors = &Units[i]->RescuedFrom->UnitColors; } else { Units[i]->Colors = &Units[i]->Player->UnitColors; } } GameResult = GameNoResult; CommandLog(NULL, NoUnitP, FlushCommands, -1, -1, NoUnitP, NULL, -1); Video.ClearScreen(); }
void LiveEffectsTool::SelectChange(BOOL isSelected) { // Stub out this function if the tool isn't wanted #ifndef NO_ADVANCED_TOOLS if (isSelected) { //MessageBox(NULL, "SelectChange 1", "Debug", MB_OK); // Load the cursors if (!LoadCursors()) InformError(); // Update the list of plug-ins //MessageBox(NULL, "SelectChange 2", "Debug", MB_OK); XPEHost::UpdateEditorsList(); //MessageBox(NULL, "SelectChange 3", "Debug", MB_OK); SelRange* pSelRange = GetApplication()->FindSelection(); if (pSelRange) pSelRange->MakePartialSelectionWhole(TRUE, FALSE, TRUE); ScreenChanged(FALSE); //MessageBox(NULL, "SelectChange 4", "Debug", MB_OK); // Find the blob manager ready for later BlobManager* BlobMgr = GetApplication()->GetBlobManager(); // Create and display my info bar please if (m_pInfoBarOp != NULL) { m_pInfoBarOp->Create(); m_pInfoBarOp->SetToolActiveState(TRUE); } // Make sure that Objects blobs are on if (BlobMgr != NULL) { // Decide which blobs to display BlobStyle MyBlobs; MyBlobs.Object = TRUE; // tell the blob manager BlobMgr->ToolInterest(MyBlobs); } //MessageBox(NULL, "SelectChange 5", "Debug", MB_OK); } else { // Deselection of the tool // Get rid of all the tools cursors RemoveCursors(); // Close any open XPE editing XPEHost::EndEditLiveEffect(); // Hide and destroy my info bar please if (m_pInfoBarOp != NULL) { m_pInfoBarOp->SetToolActiveState(FALSE); // Close any open dialogs related to the info bar here m_pInfoBarOp->Delete(); } // ensure that the colour picker is working // SetColourEditorProcessing(TRUE); // ensure any tool object blobs are removed. BlobManager* BlobMgr = GetApplication()->GetBlobManager(); if (BlobMgr != NULL) { BlobStyle bsRemoves; bsRemoves.ToolObject = TRUE; BlobMgr->RemoveInterest(bsRemoves); } } #endif // NO_ADVANCED_TOOLS }