private void UpdateGuiParams(idUserInterface gui, idDict args) { if((gui == null) || (args == null)) { return; } foreach(KeyValuePair<string, string> kvp in args.MatchPrefix("gui_parm")) { gui.State.Set(kvp.Key, kvp.Value); } gui.State.Set("noninteractive", args.GetBool("gui_noninteractive")); gui.StateChanged(idR.Game.Time); }
private void LoadLoadingInterface(string mapName) { // load / program a gui to stay up on the screen while loading string mapPath = string.Format("guis/map/{0}.gui", Path.GetFileNameWithoutExtension(mapName)); // give the gamecode a chance to override mapPath = idE.Game.GetMapLoadingInterface(mapPath); if(idE.UIManager.Exists(mapPath) == true) { _guiLoading = idE.UIManager.FindInterface(mapPath, true, false, true); } else { _guiLoading = idE.UIManager.FindInterface("guis/map/loading.gui", true, false, true); } _guiLoading.State.Set("map_loading", 0.0f); }
public idWindow(idUserInterface gui) { _gui = gui; Init(); }
public void Draw(idUserInterface hud) { idRenderView renderView = _player.RenderView; if(idR.CvarSystem.GetBool("g_skipViewEffects") == true) { SingleView(hud, renderView); } else { // TODO: /*if(player->GetInfluenceMaterial() || player->GetInfluenceEntity()) { InfluenceVision(hud, view); } else if(gameLocal.time < dvFinishTime) { DoubleVision(hud, view, dvFinishTime - gameLocal.time); } else if(player->PowerUpActive(BERSERK)) { BerserkVision(hud, view); } else*/ { SingleView(hud, renderView); } // TODO: ScreenFade(); } /* TODO: lagometer if(net_clientLagOMeter.GetBool() && lagoMaterial && gameLocal.isClient) { renderSystem->SetColor4(1.0f, 1.0f, 1.0f, 1.0f); renderSystem->DrawStretchPic(10.0f, 380.0f, 64.0f, 64.0f, 0.0f, 0.0f, 1.0f, 1.0f, lagoMaterial); }*/ }
/// <summary> /// This is called after parsing an EntityDef and for each entity spawnArgs before /// merging the entitydef. It could be done post-merge, but that would /// avoid the fast pre-cache check associated with each entityDef. /// </summary> /// <param name="dict"></param> public override void CacheDictionaryMedia(idDict dict) { #region Model foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("model")) { // precache model/animations if((kvp.Value != string.Empty) && (idR.DeclManager.FindType<idDecl>(DeclType.ModelDef, kvp.Value, false) == null)) { // precache the render model idR.RenderModelManager.FindModel(kvp.Value); // precache .cm files only idR.CollisionModelManager.LoadModel(kvp.Value, true); } } #endregion #region Gui foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("gui")) { string keyLower = kvp.Key.ToLower(); if((keyLower == "gui_noninteractive") || (keyLower.StartsWith("gui_parm") == true) || (keyLower == "gui_inventory")) { // unfortunate flag names, they aren't actually a gui } else { idR.DeclManager.MediaPrint(string.Format("Precaching gui {0}", kvp.Value)); idUserInterface gui = new idUserInterface(); if(gui != null) { gui.InitFromFile(kvp.Value); idE.UIManager.Remove(gui); } } } #endregion #region Fx foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("fx")) { idR.DeclManager.MediaPrint(string.Format("Precaching fx {0}", kvp.Value)); idR.DeclManager.FindType<idDecl>(DeclType.Fx, kvp.Value); } #endregion #region Smoke foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("smoke")) { string prtName = kvp.Value; int dash = prtName.IndexOf('-'); if(dash > 0) { prtName = prtName.Substring(0, dash); } idR.DeclManager.FindType(DeclType.Particle, prtName); } #endregion #region Skin foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("skin")) { idR.DeclManager.MediaPrint(string.Format("Precaching skin {0}", kvp.Value)); idR.DeclManager.FindType(DeclType.Skin, kvp.Value); } #endregion #region Def foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix("def")) { FindEntityDef(kvp.Value, false); } #endregion #region Misc string value = dict.GetString("s_shader"); if(value != string.Empty) { idR.DeclManager.FindType<idDecl>(DeclType.Sound, value); } value = dict.GetString("texture"); if(value != string.Empty) { idR.DeclManager.FindType<idDecl>(DeclType.Material, value); } Dictionary<string, DeclType> cacheElements = new Dictionary<string, DeclType>() { { "snd", DeclType.Sound }, { "mtr", DeclType.Material }, { "inv_icon", DeclType.Material }, { "pda_name", DeclType.Pda }, { "video", DeclType.Video }, { "audio", DeclType.Audio } }; foreach(KeyValuePair<string, DeclType> element in cacheElements) { foreach(KeyValuePair<string, string> kvp in dict.MatchPrefix(element.Key)) { idR.DeclManager.FindType<idDecl>(element.Value, kvp.Value); } } #endregion }
public idListWindow(idDeviceContext context, idUserInterface gui) : base(gui, context) { Init(); }
private void DispatchCommand(idUserInterface gui, string menuCommand, bool doIngame) { if(gui == null) { gui = _guiActive; } if(gui == _guiMainMenu) { idConsole.Warning("TODO: HandleMainMenuCommands( menuCommand );"); } else if(gui == _guiIntro) { idConsole.Warning("TODO: HandleIntroMenuCommands( menuCommand );"); } else if(gui == _guiMsg) { idConsole.Warning("TODO: HandleMsgCommands( menuCommand );"); } else if(gui == _guiTakeNotes) { idConsole.Warning("TODO: HandleNoteCommands( menuCommand );"); } else if(gui == _guiRestartMenu) { idConsole.Warning("TODO: HandleRestartMenuCommands( menuCommand );"); } else if((idE.Game != null) && (_guiActive != null) && (_guiActive.State.GetBool("gameDraw") == true)) { string cmd = idE.Game.HandleGuiCommands(menuCommand); if(cmd == null) { _guiActive = null; } else if(cmd.Equals("main", StringComparison.OrdinalIgnoreCase) == true) { StartMenu(); } else if(cmd.Contains("sound ") == true) { // pipe the GUI sound commands not handled by the game to the main menu code idConsole.Warning("TODO: HandleMainMenuCommands( cmd );"); } } else if(_guiHandle != null) { idConsole.Warning("TODO: if ( (*guiHandle)( menuCommand ) ) {"); /*if ( (*guiHandle)( menuCommand ) ) { return; }*/ } else if(doIngame == false) { idConsole.DeveloperWriteLine("idSessionLocal.DispatchCommand: no dispatch found for command '{0}'", menuCommand); } else { idConsole.Warning("TODO: HandleInGameCommands( menuCommand );"); } }
public void SetUserInterface(idUserInterface ui, /* TODO: HandleGuiCommand_t*/ object handle) { _guiActive = ui; _guiHandle = handle; if(_guiMsgRestore != null) { idConsole.DeveloperWriteLine("idSession::SetUserInterface: cleared an active message box"); _guiMsgRestore = null; } if(_guiActive == null) { return; } if(_guiActive == _guiMainMenu) { idConsole.Warning("TODO: SetSaveGameGuiVars();"); SetMainMenuVariables(); } else if(_guiActive == _guiRestartMenu) { idConsole.Warning("TODO: SetSaveGameGuiVars();"); } _guiActive.HandleEvent(new SystemEvent(SystemEventType.None), idE.System.FrameTime); _guiActive.Activate(true, idE.System.FrameTime); }
public void Remove(idUserInterface ui) { if(_guiList.Contains(ui) == true) { _guiList.Remove(ui); } if(ui.Disposed == false) { ui.Dispose(); } }
public idUserInterface FindInterface(string path, bool autoLoad = false, bool needUnique = false, bool forceNotUnique = false) { foreach(idUserInterface gui in _guiList) { if(gui.SourceFile.Equals(path, StringComparison.OrdinalIgnoreCase) == true) { if((forceNotUnique == false) && ((needUnique == true) || (gui.IsInteractive == true))) { break; } gui.AddReference(); return gui; } } if(autoLoad == true) { idUserInterface gui = new idUserInterface(); if(gui.InitFromFile(path) == true) { gui.IsUnique = (forceNotUnique == true) ? false : needUnique; return gui; } } return null; }
public idSliderWindow(idUserInterface gui) : base(gui) { Init(); }
public idChoiceWindow(idUserInterface gui) : base(gui) { Init(); }
public idWindow(idUserInterface gui, idDeviceContext context) { _context = context; _gui = gui; Init(); }
/// <summary> /// Called in an orderly fashion at system startup, so commands, cvars, files, etc are all available. /// </summary> public void Init() { idConsole.WriteLine("-------- Initializing Session --------"); // TODO: commands /*cmdSystem->AddCommand( "writePrecache", Sess_WritePrecache_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "writes precache commands" ); #ifndef ID_DEDICATED*/ idE.CmdSystem.AddCommand("map", "loads a map", CommandFlags.System, Cmd_Map /* TODO: idCmdSystem::ArgCompletion_MapName*/); /*cmdSystem->AddCommand( "devmap", Session_DevMap_f, CMD_FL_SYSTEM, "loads a map in developer mode", idCmdSystem::ArgCompletion_MapName ); cmdSystem->AddCommand( "testmap", Session_TestMap_f, CMD_FL_SYSTEM, "tests a map", idCmdSystem::ArgCompletion_MapName ); cmdSystem->AddCommand( "writeCmdDemo", Session_WriteCmdDemo_f, CMD_FL_SYSTEM, "writes a command demo" ); cmdSystem->AddCommand( "playCmdDemo", Session_PlayCmdDemo_f, CMD_FL_SYSTEM, "plays back a command demo" ); cmdSystem->AddCommand( "timeCmdDemo", Session_TimeCmdDemo_f, CMD_FL_SYSTEM, "times a command demo" ); cmdSystem->AddCommand( "exitCmdDemo", Session_ExitCmdDemo_f, CMD_FL_SYSTEM, "exits a command demo" ); cmdSystem->AddCommand( "aviCmdDemo", Session_AVICmdDemo_f, CMD_FL_SYSTEM, "writes AVIs for a command demo" ); cmdSystem->AddCommand( "aviGame", Session_AVIGame_f, CMD_FL_SYSTEM, "writes AVIs for the current game" ); cmdSystem->AddCommand( "recordDemo", Session_RecordDemo_f, CMD_FL_SYSTEM, "records a demo" ); cmdSystem->AddCommand( "stopRecording", Session_StopRecordingDemo_f, CMD_FL_SYSTEM, "stops demo recording" ); cmdSystem->AddCommand( "playDemo", Session_PlayDemo_f, CMD_FL_SYSTEM, "plays back a demo", idCmdSystem::ArgCompletion_DemoName ); cmdSystem->AddCommand( "timeDemo", Session_TimeDemo_f, CMD_FL_SYSTEM, "times a demo", idCmdSystem::ArgCompletion_DemoName ); cmdSystem->AddCommand( "timeDemoQuit", Session_TimeDemoQuit_f, CMD_FL_SYSTEM, "times a demo and quits", idCmdSystem::ArgCompletion_DemoName ); cmdSystem->AddCommand( "aviDemo", Session_AVIDemo_f, CMD_FL_SYSTEM, "writes AVIs for a demo", idCmdSystem::ArgCompletion_DemoName ); cmdSystem->AddCommand( "compressDemo", Session_CompressDemo_f, CMD_FL_SYSTEM, "compresses a demo file", idCmdSystem::ArgCompletion_DemoName ); #endif cmdSystem->AddCommand( "disconnect", Session_Disconnect_f, CMD_FL_SYSTEM, "disconnects from a game" ); cmdSystem->AddCommand( "demoShot", Session_DemoShot_f, CMD_FL_SYSTEM, "writes a screenshot for a demo" ); cmdSystem->AddCommand( "testGUI", Session_TestGUI_f, CMD_FL_SYSTEM, "tests a gui" ); #ifndef ID_DEDICATED cmdSystem->AddCommand( "saveGame", SaveGame_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "saves a game" ); cmdSystem->AddCommand( "loadGame", LoadGame_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "loads a game", idCmdSystem::ArgCompletion_SaveGame ); #endif cmdSystem->AddCommand( "takeViewNotes", TakeViewNotes_f, CMD_FL_SYSTEM, "take notes about the current map from the current view" ); cmdSystem->AddCommand( "takeViewNotes2", TakeViewNotes2_f, CMD_FL_SYSTEM, "extended take view notes" ); cmdSystem->AddCommand( "rescanSI", Session_RescanSI_f, CMD_FL_SYSTEM, "internal - rescan serverinfo cvars and tell game" ); cmdSystem->AddCommand( "promptKey", Session_PromptKey_f, CMD_FL_SYSTEM, "prompt and sets the CD Key" ); cmdSystem->AddCommand( "hitch", Session_Hitch_f, CMD_FL_SYSTEM|CMD_FL_CHEAT, "hitches the game" );*/ // the same idRenderWorld will be used for all games // and demos, insuring that level specific models // will be freed _renderWorld = idE.RenderSystem.CreateRenderWorld(); idConsole.Warning("TODO: init sound"); /*sw = soundSystem->AllocSoundWorld( rw ); menuSoundWorld = soundSystem->AllocSoundWorld( rw );*/ // we have a single instance of the main menu _guiMainMenu = idE.UIManager.FindInterface("guis/mainmenu.gui", true, false, true); idConsole.Warning("TODO: map list"); /*guiMainMenu_MapList = uiManager->AllocListGUI(); guiMainMenu_MapList->Config(guiMainMenu, "mapList"); idAsyncNetwork::client.serverList.GUIConfig(guiMainMenu, "serverList");*/ _guiRestartMenu = idE.UIManager.FindInterface("guis/restart.gui", true, false, true); _guiGameOver = idE.UIManager.FindInterface("guis/gameover.gui", true, false, true); _guiMsg = idE.UIManager.FindInterface("guis/msg.gui", true, false, true); _guiTakeNotes = idE.UIManager.FindInterface("guis/takeNotes.gui", true, false, true); _guiIntro = idE.UIManager.FindInterface("guis/intro.gui", true, false, true); _whiteMaterial = idE.DeclManager.FindMaterial("_white"); idConsole.WriteLine("session initialized"); idConsole.WriteLine("--------------------------------------"); }
internal idUserInterface FindInternalInterface(idUserInterface gui) { return _guiList.Find(u => u == gui); }
public bool ProcessEvent(SystemEvent ev) { // hitting escape anywhere brings up the menu if((_guiActive == null) && (ev.Type == SystemEventType.Key) && (ev.Value2 == 1) && (ev.Value == (int) Keys.Escape)) { idConsole.Warning("TODO: escape"); /*console->Close(); if ( game ) { idUserInterface *gui = NULL; escReply_t op; op = game->HandleESC( &gui ); if ( op == ESC_IGNORE ) { return true; } else if ( op == ESC_GUI ) { SetGUI( gui, NULL ); return true; } } StartMenu(); return true;*/ } // let the pull-down console take it if desired if(idE.Console.ProcessEvent(ev, false) == true) { return true; } // if we are testing a GUI, send all events to it if(_guiTest != null) { // hitting escape exits the testgui if((ev.Type == SystemEventType.Key) && (ev.Value2 == 1) && (ev.Value == (int) Keys.Escape)) { _guiTest = null; return true; } string cmd = _guiTest.HandleEvent(ev, idE.System.FrameTime); if(cmd != string.Empty) { idConsole.WriteLine("testGui event returned: '{0}'", cmd); } return true; } // menus / etc if(_guiActive != null) { ProcessMenuEvent(ev); return true; } // if we aren't in a game, force the console to take it if(_mapSpawned == false) { idE.Console.ProcessEvent(ev, true); return true; } // in game, exec bindings for all key downs if((ev.Type == SystemEventType.Key) && (ev.Value2 == 1)) { idConsole.Warning("TODO: idKeyInput::ExecKeyBinding( event->evValue );"); return true; } return false; }
internal void AddInternalInterface(idUserInterface gui) { _guiList.Add(gui); }
private void DispatchCommand(idUserInterface gui, string menuCommand) { DispatchCommand(gui, menuCommand, true); }
public idSimpleWindow(idWindow win) { _gui = win.UserInterface; _context = win.DeviceContext; _drawRect = win.DrawRectangle; _clientRect = win.ClientRectangle; _textRect = win.TextRectangle; _origin = win.Origin; _fontFamily = win.FontFamily; _name = win.Name; _materialScaleX = win.MaterialScaleX; _materialScaleY = win.MaterialScaleY; _borderSize = win.BorderSize; _textAlign = win.TextAlign; _textAlignX = win.TextAlignX; _textAlignY = win.TextAlignY; _background = win.Background; _flags = win.Flags; _textShadow = win.TextShadow; _visible.Set(win.IsVisible); _text.Set(win.Text); _rect.Set(win.Rectangle); _backColor.Set(win.BackColor); _materialColor.Set(win.MaterialColor); _foreColor.Set(win.ForeColor); _borderColor.Set(win.BorderColor); _textScale.Set(win.TextScale); _rotate.Set(win.Rotate); _shear.Set(win.Shear); _backgroundName.Set(win.BackgroundName); if(_backgroundName != string.Empty) { _background = idE.DeclManager.FindMaterial(_backgroundName); _background.Sort = (float) MaterialSort.Gui; ; _background.ImageClassification = 1; // just for resource tracking } _backgroundName.Material = _background; _parent = win.Parent; _hideCursor.Set(win.HideCursor); if(_parent != null) { if(_text.NeedsUpdate == true) { _parent.AddUpdateVariable(_text); } if(_visible.NeedsUpdate == true) { _parent.AddUpdateVariable(_visible); } if(_rect.NeedsUpdate == true) { _parent.AddUpdateVariable(_rect); } if(_backColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_backColor); } if(_materialColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_materialColor); } if(_foreColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_foreColor); } if(_borderColor.NeedsUpdate == true) { _parent.AddUpdateVariable(_borderColor); } if(_textScale.NeedsUpdate == true) { _parent.AddUpdateVariable(_textScale); } if(_rotate.NeedsUpdate == true) { _parent.AddUpdateVariable(_rotate); } if(_shear.NeedsUpdate == true) { _parent.AddUpdateVariable(_shear); } if(_backgroundName.NeedsUpdate == true) { _parent.AddUpdateVariable(_backgroundName); } } }
public idListWindow(idUserInterface gui) : base(gui) { Init(); }
private void Clear() { _description = "<none>"; _renderBump = string.Empty; _contentFlags = ContentFlags.Solid; _surfaceFlags = SurfaceFlags.None; _materialFlags = 0; _sort = (float) MaterialSort.Bad; _coverage = MaterialCoverage.Bad; _cullType = CullType.Front; _deformType = DeformType.None; _deformRegisters = new int[4]; _ops = null; _expressionRegisters = null; _constantRegisters = null; _stages = new MaterialStage[] { }; _stageCount = 0; _ambientStageCount = 0; _registerCount = 0; _lightFalloffImage = null; _entityGui = 0; _shouldCreateBackSides = false; _editorImageName = null; _fogLight = false; _blendLight = false; _ambientLight = false; _noFog = false; _hasSubview = false; _allowOverlays = true; _unsmoothedTangents = false; _userInterface = null; _referenceCount = 0; /*editorAlpha = 1.0;*/ _spectrum = 0; _polygonOffset = 0; _suppressInSubview = false; _portalSky = false; _decalInfo.StayTime = 10000; _decalInfo.FadeTime = 4000; _decalInfo.Start = new float[] { 1, 1, 1, 1 }; _decalInfo.End = new float[] { 0, 0, 0, 0 }; }
public /*override*/ void HandleMainMenuCommands(string menuCommand, idUserInterface gui) { idConsole.DeveloperWriteLine("HandleMainMenuCommands"); }
/// <summary> /// Parses the material, if there are any errors during parsing the defaultShader will be set. /// </summary> /// <param name="lexer"></param> private void ParseMaterial(idLexer lexer) { _registerCount = PredefinedRegisterCount; // leave space for the parms to be copied in. for(int i = 0; i < _registerCount; i++) { _parsingData.RegisterIsTemporary[i] = true; // they aren't constants that can be folded. } TextureRepeat textureRepeatDefault = TextureRepeat.Repeat; // allow a global setting for repeat. idToken token = null; string tokenValue; string tokenLower; int count; while(true) { if(TestMaterialFlag(Renderer.MaterialFlags.Defaulted) == true) { // we have a parse error. return; } if((token = lexer.ExpectAnyToken()) == null) { this.MaterialFlag = MaterialFlags.Defaulted; return; } tokenValue = token.ToString(); tokenLower = tokenValue.ToLower(); // end of material definition if(tokenLower == "}") { break; } else if(tokenLower == "qer_editorimage") { token = lexer.ReadTokenOnLine(); _editorImageName = (token != null) ? token.ToString() : string.Empty; lexer.SkipRestOfLine(); } else if(tokenLower == "description") { token = lexer.ReadTokenOnLine(); _description = (token != null) ? token.ToString() : string.Empty; } // check for the surface / content bit flags. else if(CheckSurfaceParameter(token) == true) { } else if(tokenLower == "polygonoffset") { this.MaterialFlag = Renderer.MaterialFlags.PolygonOffset; if((token = lexer.ReadTokenOnLine()) == null) { _polygonOffset = 1; } else { _polygonOffset = token.ToFloat(); } } // noshadow. else if(tokenLower == "noshadows") { this.MaterialFlag = MaterialFlags.NoShadows; } else if(tokenLower == "suppressinsubview") { _suppressInSubview = true; } else if(tokenLower == "portalsky") { _portalSky = true; } else if(tokenLower == "noselfshadow") { this.MaterialFlag = Renderer.MaterialFlags.NoSelfShadow; } else if(tokenLower == "noportalfog") { this.MaterialFlag = Renderer.MaterialFlags.NoPortalFog; } // forceShadows allows nodraw surfaces to cast shadows. else if(tokenLower == "forceshadows") { this.MaterialFlag = Renderer.MaterialFlags.ForceShadows; } // overlay / decal suppression. else if(tokenLower == "nooverlays") { _allowOverlays = false; } // moster blood overlay forcing for alpha tested or translucent surfaces. else if(tokenLower == "forceoverlays") { _parsingData.ForceOverlays = true; } else if(tokenLower == "translucent") { _coverage = MaterialCoverage.Translucent; } // global zero clamp. else if(tokenLower == "zeroclamp") { textureRepeatDefault = TextureRepeat.ClampToZero; } // global clamp. else if(tokenLower == "clamp") { textureRepeatDefault = TextureRepeat.Clamp; } // global clamp. else if(tokenLower == "alphazeroclamp") { textureRepeatDefault = TextureRepeat.ClampToZero; } // forceOpaque is used for skies-behind-windows. else if(tokenLower == "forceopaque") { _coverage = MaterialCoverage.Opaque; } else if(tokenLower == "twosided") { _cullType = CullType.TwoSided; // twoSided implies no-shadows, because the shadow // volume would be coplanar with the surface, giving depth fighting // we could make this no-self-shadows, but it may be more important // to receive shadows from no-self-shadow monsters. this.MaterialFlag = Renderer.MaterialFlags.NoShadows; } else if(tokenLower == "backsided") { _cullType = CullType.Back; // the shadow code doesn't handle this, so just disable shadows. // We could fix this in the future if there was a need. this.MaterialFlag = Renderer.MaterialFlags.NoShadows; } else if(tokenLower == "foglight") { _fogLight = true; } else if(tokenLower == "blendlight") { _blendLight = true; } else if(tokenLower == "ambientlight") { _ambientLight = true; } else if(tokenLower == "mirror") { _sort = (float) MaterialSort.Subview; _coverage = MaterialCoverage.Opaque; } else if(tokenLower == "nofog") { _noFog = true; } else if(tokenLower == "unsmoothedtangents") { _unsmoothedTangents = true; } // lightFallofImage <imageprogram> // specifies the image to use for the third axis of projected // light volumes. else if(tokenLower == "lightfalloffimage") { _lightFalloffImage = idE.ImageManager.ImageFromFile(ParsePastImageProgram(lexer), TextureFilter.Default, false, TextureRepeat.Clamp, TextureDepth.Default); } // guisurf <guifile> | guisurf entity // an entity guisurf must have an idUserInterface // specified in the renderEntity. else if(tokenLower == "guisurf") { token = lexer.ReadTokenOnLine(); tokenLower = token.ToString().ToLower(); if(tokenLower == "entity") { _entityGui = 1; } else if(tokenLower == "entity2") { _entityGui = 2; } else if(tokenLower == "entity3") { _entityGui = 3; } else { _userInterface = idE.UIManager.FindInterface(token.ToString(), true); } } // sort. else if(tokenLower == "sort") { ParseSort(lexer); } // spectrum <integer>. else if(tokenLower == "spectrum") { int.TryParse(lexer.ReadTokenOnLine().ToString(), out _spectrum); } // deform < sprite | tube | flare >. else if(tokenLower == "deform") { ParseDeform(lexer); } // decalInfo <staySeconds> <fadeSeconds> (<start rgb>) (<end rgb>). else if(tokenLower == "decalinfo") { ParseDecalInfo(lexer); } // renderbump <args...>. else if(tokenLower == "renderbump") { _renderBump = lexer.ParseRestOfLine(); } // diffusemap for stage shortcut. else if(tokenLower == "diffusemap") { idLexer newLexer = new idLexer(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.NoStringEscapeCharacters | LexerOptions.AllowPathNames); newLexer.LoadMemory(string.Format("blend diffusemap\nmap {0}\n}}\n", ParsePastImageProgram(lexer)), "diffusemap"); ParseStage(newLexer, textureRepeatDefault); } // specularmap for stage shortcut. else if(tokenLower == "specularmap") { idLexer newLexer = new idLexer(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.NoStringEscapeCharacters | LexerOptions.AllowPathNames); newLexer.LoadMemory(string.Format("blend specularmap\nmap {0}\n}}\n", ParsePastImageProgram(lexer)), "specularmap"); ParseStage(newLexer, textureRepeatDefault); } // normalmap for stage shortcut. else if(tokenLower == "bumpmap") { idLexer newLexer = new idLexer(LexerOptions.NoFatalErrors | LexerOptions.NoStringConcatination | LexerOptions.NoStringEscapeCharacters | LexerOptions.AllowPathNames); newLexer.LoadMemory(string.Format("blend bumpmap\nmap {0}\n}}\n", ParsePastImageProgram(lexer)), "bumpmap"); ParseStage(newLexer, textureRepeatDefault); } // DECAL_MACRO for backwards compatibility with the preprocessor macros. else if(tokenLower == "decal_macro") { // polygonOffset this.MaterialFlag = Renderer.MaterialFlags.PolygonOffset; _polygonOffset = -1; // discrete _surfaceFlags |= SurfaceFlags.Discrete; _contentFlags &= ~ContentFlags.Solid; // sort decal. _sort = (float) MaterialSort.Decal; // noShadows this.MaterialFlag = Renderer.MaterialFlags.NoShadows; } else if(tokenValue == "{") { // create the new stage. ParseStage(lexer, textureRepeatDefault); } else { idConsole.WriteLine("unknown general material parameter '{0}' in '{1}'", tokenValue, this.Name); return; } } // add _flat or _white stages if needed. AddImplicitStages(); // order the diffuse / bump / specular stages properly. SortInteractionStages(); // if we need to do anything with normals (lighting or environment mapping) // and two sided lighting was asked for, flag // shouldCreateBackSides() and change culling back to single sided, // so we get proper tangent vectors on both sides. // we can't just call ReceivesLighting(), because the stages are still // in temporary form. if(_cullType == CullType.TwoSided) { count = _parsingData.Stages.Count; for(int i = 0; i < count; i++) { if((_parsingData.Stages[i].Lighting != StageLighting.Ambient) || (_parsingData.Stages[i].Texture.TextureCoordinates != TextureCoordinateGeneration.Explicit)) { if(_cullType == CullType.TwoSided) { _cullType = CullType.Front; _shouldCreateBackSides = true; } break; } } } // currently a surface can only have one unique texgen for all the stages on old hardware. TextureCoordinateGeneration firstGen = TextureCoordinateGeneration.Explicit; count = _parsingData.Stages.Count; for(int i = 0; i < count; i++) { if(_parsingData.Stages[i].Texture.TextureCoordinates != TextureCoordinateGeneration.Explicit) { if(firstGen == TextureCoordinateGeneration.Explicit) { firstGen = _parsingData.Stages[i].Texture.TextureCoordinates; } else if(firstGen != _parsingData.Stages[i].Texture.TextureCoordinates) { idConsole.Warning("material '{0}' has multiple stages with a texgen", this.Name); break; } } } }
public override void Spawn() { base.Spawn(); if(this.Index >= idR.MaxClients) { idConsole.Error("entityIndex > MAX_CLIENTS for player. Player may only be spawned with a client."); } // allow thinking during cinematics this.Cinematic = true; if(idR.Game.IsMultiplayer == true) { // always start in spectating state waiting to be spawned in // do this before SetClipModel to get the right bounding box this.IsSpectating = true; } // set our collision model _physicsObject.Self = this; SetClipModel(); _physicsObject.SetMass(this.SpawnArgs.GetFloat("mass", 100)); _physicsObject.SetContents(ContentFlags.Body); _physicsObject.SetClipMask(ContentFlags.MaskPlayerSolid); SetPhysics(_physicsObject); idConsole.Warning("TODO: InitAASLocation();"); _skin = this.RenderEntity.CustomSkin; // only the local player needs guis if((idR.Game.IsMultiplayer == false) || (this.Index == idR.Game.LocalClientIndex)) { // load HUD if(idR.Game.IsMultiplayer == true) { _hud = idR.UIManager.FindInterface("guis/mphud.gui", true, false, true); } else { string temp = this.SpawnArgs.GetString("hud", ""); if(temp != string.Empty) { _hud = idR.UIManager.FindInterface(temp, true, false, true); } } if(_hud != null) { _hud.Activate(true, idR.Game.Time); } // load cursor string cursor = this.SpawnArgs.GetString("cursor", ""); if(cursor != string.Empty) { _cursor = idR.UIManager.FindInterface(cursor, true, idR.Game.IsMultiplayer, idR.Game.IsMultiplayer); } if(_cursor != null) { _cursor.Activate(true, idR.Game.Time); } // TODO // objectiveSystem = uiManager->FindGui( "guis/pda.gui", true, false, true ); // objectiveSystemOpen = false; } /*SetLastHitTime( 0 ); // load the armor sound feedback declManager->FindSound( "player_sounds_hitArmor" ); // set up conditions for animation LinkScriptVariables(); animator.RemoveOriginOffset( true );*/ // initialize user info related settings // on server, we wait for the userinfo broadcast, as this controls when the player is initially spawned in game if((idR.Game.IsClient == true) || (this.Index == idR.Game.LocalClientIndex)) { UserInfoChanged(false); } // create combat collision hull for exact collision detection /*SetCombatModel();*/ // supress model in non-player views, but allow it in mirrors and remote views this.RenderEntity.SuppressSurfaceInViewID = this.Index + 1; // don't project shadow on self or weapon this.RenderEntity.NoSelfShadow = true; /*idAFAttachment *headEnt = head.GetEntity(); if ( headEnt ) { headEnt->GetRenderEntity()->suppressSurfaceInViewID = entityNumber+1; headEnt->GetRenderEntity()->noSelfShadow = true; }*/ if(idR.Game.IsMultiplayer == true) { Init(); Hide(); // properly hidden if starting as a spectator if(idR.Game.IsClient == false) { // set yourself ready to spawn. idMultiplayerGame will decide when/if appropriate and call SpawnFromSpawnSpot // TODO /*SetupWeaponEntity();*/ SpawnFromSpawnSpot(); _forceRespawn = true; } } else { idConsole.Warning("TODO: SetupWeaponEntity();"); SpawnFromSpawnSpot(); } // trigger playtesting item gives, if we didn't get here from a previous level // the devmap key will be set on the first devmap, but cleared on any level // transitions if((idR.Game.IsMultiplayer == false) && (idR.Game.ServerInfo.ContainsKey("devmap") == true)) { idConsole.Warning("TODO: devmap"); // fire a trigger with the name "devmap" /*idEntity *ent = gameLocal.FindEntity( "devmap" ); if ( ent ) { ent->ActivateTargets( this ); }*/ } if(_hud != null) { idConsole.Warning("TODO: soul cube"); // we can spawn with a full soul cube, so we need to make sure the hud knows this /*if ( weapon_soulcube > 0 && ( inventory.weapons & ( 1 << weapon_soulcube ) ) ) { int max_souls = inventory.MaxAmmoForAmmoClass( this, "ammo_souls" ); if ( inventory.ammo[ idWeapon::GetAmmoNumForName( "ammo_souls" ) ] >= max_souls ) { hud->HandleNamedEvent( "soulCubeReady" ); } }*/ _hud.HandleNamedEvent("itemPickup"); } idConsole.Warning("TODO: GetPDA"); /*if ( GetPDA() ) { // Add any emails from the inventory for ( int i = 0; i < inventory.emails.Num(); i++ ) { GetPDA()->AddEmail( inventory.emails[i] ); } GetPDA()->SetSecurity( common->GetLanguageDict()->GetString( "#str_00066" ) ); }*/ if(idR.Game.World.SpawnArgs.GetBool("no_Weapons") == true) { idConsole.Warning("TODO: no_Weapons"); /*hiddenWeapon = true; if ( weapon.GetEntity() ) { weapon.GetEntity()->LowerWeapon(); } idealWeapon = 0;*/ } else { idConsole.Warning("TODO: hiddenWeapon = false;"); } if(_hud != null) { idConsole.Warning("TODO: UpdateHudWeapon();"); _hud.StateChanged(idR.Game.Time); } idConsole.Warning("TODO: inventory"); /*tipUp = false; objectiveUp = false; if ( inventory.levelTriggers.Num() ) { PostEventMS( &EV_Player_LevelTrigger, 0 ); } inventory.pdaOpened = false; inventory.selPDA = 0;*/ if(idR.Game.IsMultiplayer == false) { int skill = idR.CvarSystem.GetInteger("g_skill"); if(skill < 2) { if(this.Health < 25) { this.Health = 25; } if(idR.CvarSystem.GetBool("g_useDynamicProtection") == true) { idR.CvarSystem.SetFloat("g_damageScale", 1.0f); } } else { idR.CvarSystem.SetFloat("g_damageScale", 1.0f); idR.CvarSystem.SetFloat("g_armorProtection", (skill < 2) ? 0.4f : 0.2f); if(skill == 3) { idConsole.Warning("TODO: this.HealthTake = true"); idConsole.Warning("TODO: nextHealthTake = gameLocal.time + g_healthTakeTime.GetInteger() * 1000;"); } } } }
public idChoiceWindow(idUserInterface gui) : base(gui) { Init(); }
private void SingleView(idUserInterface hud, idRenderView renderView) { // normal rendering if(renderView == null) { return; } // place the sound origin for the player // TODO: gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1, gameLocal.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); // if the objective system is up, don't do normal drawing // TODO: objectives /*if ( player->objectiveSystemOpen ) { player->objectiveSystem->Redraw( gameLocal.time ); return; } */ // hack the shake in at the very last moment, so it can't cause any consistency problems idRenderView hackedView = renderView.Copy(); // TODO: hackedView.viewaxis = hackedView.viewaxis * ShakeAxis(); idR.Game.CurrentRenderWorld.RenderScene(hackedView); if(_player.IsSpectating == true) { return; } // draw screen blobs if((idR.CvarSystem.GetBool("pm_thirdPerson") == false) && (idR.CvarSystem.GetBool("g_skipViewEffects") == false)) { idConsole.Warning("TODO: screen blobs"); /*for ( int i = 0 ; i < MAX_SCREEN_BLOBS ; i++ ) { screenBlob_t *blob = &screenBlobs[i]; if ( blob->finishTime <= gameLocal.time ) { continue; } blob->y += blob->driftAmount; float fade = (float)( blob->finishTime - gameLocal.time ) / ( blob->finishTime - blob->startFadeTime ); if ( fade > 1.0f ) { fade = 1.0f; } if ( fade ) { renderSystem->SetColor4( 1,1,1,fade ); renderSystem->DrawStretchPic( blob->x, blob->y, blob->w, blob->h,blob->s1, blob->t1, blob->s2, blob->t2, blob->material ); } } player->DrawHUD( hud ); // armor impulse feedback float armorPulse = ( gameLocal.time - player->lastArmorPulse ) / 250.0f; if ( armorPulse > 0.0f && armorPulse < 1.0f ) { renderSystem->SetColor4( 1, 1, 1, 1.0 - armorPulse ); renderSystem->DrawStretchPic( 0, 0, 640, 480, 0, 0, 1, 1, armorMaterial ); } // tunnel vision float health = 0.0f; if ( g_testHealthVision.GetFloat() != 0.0f ) { health = g_testHealthVision.GetFloat(); } else { health = player->health; } float alpha = health / 100.0f; if ( alpha < 0.0f ) { alpha = 0.0f; } if ( alpha > 1.0f ) { alpha = 1.0f; } if ( alpha < 1.0f ) { renderSystem->SetColor4( ( player->health <= 0.0f ) ? MS2SEC( gameLocal.time ) : lastDamageTime, 1.0f, 1.0f, ( player->health <= 0.0f ) ? 0.0f : alpha ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, tunnelMaterial ); } if ( player->PowerUpActive(BERSERK) ) { int berserkTime = player->inventory.powerupEndTime[ BERSERK ] - gameLocal.time; if ( berserkTime > 0 ) { // start fading if within 10 seconds of going away alpha = (berserkTime < 10000) ? (float)berserkTime / 10000 : 1.0f; renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, alpha ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, berserkMaterial ); } } if ( bfgVision ) { renderSystem->SetColor4( 1.0f, 1.0f, 1.0f, 1.0f ); renderSystem->DrawStretchPic( 0.0f, 0.0f, 640.0f, 480.0f, 0.0f, 0.0f, 1.0f, 1.0f, bfgMaterial ); }*/ } // test a single material drawn over everything if(idR.CvarSystem.GetString("g_testPostProcess") != string.Empty) { idMaterial material = idR.DeclManager.FindMaterial(idR.CvarSystem.GetString("g_testPostProcess"), false); if(material == null) { idConsole.Warning("Material not found."); idR.CvarSystem.SetString("g_testPostProcess", string.Empty); } else { idR.RenderSystem.Color = new Vector4(1, 1, 1, 1); idR.RenderSystem.DrawStretchPicture(0, 0, idE.VirtualScreenWidth, idE.VirtualScreenHeight, 0, 0, 1, 1, material); } } }
private void Dispose(bool disposing) { if(this.Disposed == true) { throw new ObjectDisposedException(this.GetType().Name); } if(disposing == true) { CleanUp(); _gui = null; _context = null; _parent = null; _background = null; _focusedChild = null; _captureChild = null; _overChild = null; _children = null; _drawWindows = null; _definedVariables = null; _updateVariables = null; _scripts = null; _timeLineEvents = null; _transitions = null; _namedEvents = null; _expressionRegisters = null; _ops = null; _regList = null; _lastEval = null; _builtInVariables = null; } _disposed = true; }