void GAMECLIENT::update_local_character_pos() { if(config.cl_predict && client_state() != CLIENTSTATE_DEMOPLAYBACK) { if(!snap.local_character || (snap.local_character->health < 0) || (snap.gameobj && snap.gameobj->game_over)) { // don't use predicted } else local_character_pos = mix(predicted_prev_char.pos, predicted_char.pos, client_predintratick()); } else if(snap.local_character && snap.local_prev_character) { local_character_pos = mix( vec2(snap.local_prev_character->x, snap.local_prev_character->y), vec2(snap.local_character->x, snap.local_character->y), client_intratick()); } if(spectate_cid == -1) freeview = true; if(snap.spectate && !freeview) { if(!snap.characters[spectate_cid].active || clients[spectate_cid].team == -1) { freeview = true; return; } spectate_pos = mix( vec2(snap.characters[spectate_cid].prev.x, snap.characters[spectate_cid].prev.y), vec2(snap.characters[spectate_cid].cur.x, snap.characters[spectate_cid].cur.y), client_intratick()); } }
void _mesa_EnableClientState( GLenum cap ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); client_state( ctx, cap, GL_TRUE ); }
/************************************************************************** Called when the return key is pressed. **************************************************************************/ static void inputline_return(GtkEntry *w, gpointer data) { const char *theinput; theinput = gtk_entry_get_text(w); if (*theinput) { if (client_state() == C_S_RUNNING && gui_gtk2_allied_chat_only && is_plain_public_message(theinput)) { char buf[MAX_LEN_MSG]; fc_snprintf(buf, sizeof(buf), ". %s", theinput); send_chat(buf); } else { send_chat(theinput); } if (genlist_size(history_list) >= MAX_CHATLINE_HISTORY) { void *data; data = genlist_get(history_list, -1); genlist_remove(history_list, data); free(data); } genlist_prepend(history_list, fc_strdup(theinput)); history_pos=-1; } gtk_entry_set_text(w, ""); }
/** * Disable GL capability. * \param cap state to enable/disable. * * Get's the current context, assures that we're outside glBegin()/glEnd() and * calls client_state(). */ void GLAPIENTRY _mesa_DisableClientState( GLenum cap ) { GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); client_state( ctx, cap, GL_FALSE ); }
void HUD::on_render() { if(!gameclient.snap.gameobj) return; width = 300*gfx_screenaspect(); bool spectate = false; if(gameclient.snap.local_info && gameclient.snap.local_info->team == -1) spectate = true; if(!config.cl_clear_hud && !config.cl_clear_all && gameclient.snap.local_character && !spectate && !(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over)) { render_healthandammo(); render_speed(); } render_goals(); render_fps(); if(client_state() != CLIENTSTATE_DEMOPLAYBACK) render_connectionwarning(); render_teambalancewarning(); if(config.cl_render_vote && !config.cl_clear_all) render_voting(); if(config.cl_render_crosshair && !config.cl_clear_hud && !config.cl_clear_all) render_cursor(); if(config.cl_render_viewmode && !config.cl_clear_hud && !config.cl_clear_all && spectate && !(gameclient.snap.gameobj && gameclient.snap.gameobj->game_over)) render_spectate(); }
// TODO(stevescott): test void ASSR::simulate_initial_state(VectorView state0)const { // First, simulate the initial state of the client state vector. VectorView client_state(state0, 0, state0.size()-2); StateSpaceModelBase::simulate_initial_state(client_state); // Next simulate the initial value of the first latent weekly // observation. double mu = StateSpaceModelBase::observation_matrix(0).dot(client_state); state0[state_dimension() - 2] = rnorm(mu, regression_->sigma()); // Finally, the initial state of the cumulator variable is zero. state0[state_dimension() - 1] = 0; }
void GAMECLIENT::update_local_character_pos() { if ( config.cl_predict && client_state() != CLIENTSTATE_DEMOPLAYBACK ) { if ( snap.local_character && ( snap.local_character->health > 0 ) ) { local_character_pos = mix( predicted_prev_char.pos, predicted_char.pos, client_predintratick( ) ); } } else if( snap.local_character && snap.local_prev_character ) { local_character_pos = mix( vec2(snap.local_prev_character->x, snap.local_prev_character->y), vec2(snap.local_character->x, snap.local_character->y), client_intratick()); } }
int snd_update() { /* update volume */ int wanted_volume = config.snd_volume; if(!gfx_window_active() && config.snd_nonactive_mute) wanted_volume = 0; if(wanted_volume != sound_volume) { lock_wait(sound_lock); sound_volume = wanted_volume; lock_release(sound_lock); } if (client_state() == CLIENTSTATE_OFFLINE) snd_set_channel(1, config.music_volume * 0.01f, 0.0f); else snd_set_channel(1, config.music_ingame_volume * 0.01f, 0.0f); return 0; }
/**************************************************************************** Really resize the main window. ****************************************************************************/ static void real_resize_window_callback(void *data) { struct widget *widget; Uint32 flags = Main.screen->flags; if (gui_sdl_fullscreen) { flags |= SDL_FULLSCREEN; } else { flags &= ~SDL_FULLSCREEN; } set_video_mode(gui_sdl_screen.width, gui_sdl_screen.height, flags); if (C_S_RUNNING == client_state()) { /* Move units window to botton-right corner. */ set_new_unitinfo_window_pos(); /* Move minimap window to botton-left corner. */ set_new_minimap_window_pos(); /* Move cooling/warming icons to botton-right corner. */ widget = get_widget_pointer_form_main_list(ID_WARMING_ICON); widget_set_position(widget, (Main.screen->w - adj_size(10) - (widget->size.w * 2)), widget->size.y); widget = get_widget_pointer_form_main_list(ID_COOLING_ICON); widget_set_position(widget, (Main.screen->w - adj_size(10) - widget->size.w), widget->size.y); map_canvas_resized(Main.screen->w, Main.screen->h); update_info_label(); update_unit_info_label(get_units_in_focus()); center_on_something(); /* With redrawing full map. */ update_order_widgets(); } else { draw_intro_gfx(); dirty_all(); } flush_all(); }
int do_mode(struct session *sp,char c) { sp->useeditmode=c; client_state(sp,LM_MODE,0); return 1; }
/** * Helper function to enable or disable state. * * \param ctx GL context. * \param cap the state to enable/disable * \param state whether to enable or disable the specified capability. * * Updates the current context and flushes the vertices as needed. For * capabilities associated with extensions it verifies that those extensions * are effectivly present before updating. Notifies the driver via * dd_function_table::Enable. */ void _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) { if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "%s %s (newstate is %x)\n", state ? "glEnable" : "glDisable", _mesa_lookup_enum_by_nr(cap), ctx->NewState); switch (cap) { case GL_ALPHA_TEST: if (ctx->Color.AlphaEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.AlphaEnabled = state; break; case GL_AUTO_NORMAL: if (ctx->Eval.AutoNormal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.AutoNormal = state; break; case GL_BLEND: if (ctx->Color.BlendEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.BlendEnabled = state; break; #if FEATURE_userclip case GL_CLIP_PLANE0: case GL_CLIP_PLANE1: case GL_CLIP_PLANE2: case GL_CLIP_PLANE3: case GL_CLIP_PLANE4: case GL_CLIP_PLANE5: { const GLuint p = cap - GL_CLIP_PLANE0; if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); if (state) { ctx->Transform.ClipPlanesEnabled |= (1 << p); if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top)) _math_matrix_analyse( ctx->ProjectionMatrixStack.Top ); /* This derived state also calculated in clip.c and * from _mesa_update_state() on changes to EyeUserPlane * and ctx->ProjectionMatrix respectively. */ _mesa_transform_vector( ctx->Transform._ClipUserPlane[p], ctx->Transform.EyeUserPlane[p], ctx->ProjectionMatrixStack.Top->inv ); } else { ctx->Transform.ClipPlanesEnabled &= ~(1 << p); } } break; #endif case GL_COLOR_MATERIAL: if (ctx->Light.ColorMaterialEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_CURRENT(ctx, 0); ctx->Light.ColorMaterialEnabled = state; if (state) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); } break; case GL_CULL_FACE: if (ctx->Polygon.CullFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.CullFlag = state; break; case GL_CULL_VERTEX_EXT: CHECK_EXTENSION(EXT_cull_vertex, cap); if (ctx->Transform.CullVertexFlag == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.CullVertexFlag = state; break; case GL_DEPTH_TEST: if (ctx->Depth.Test == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.Test = state; break; case GL_DITHER: if (ctx->NoDither) { state = GL_FALSE; /* MESA_NO_DITHER env var */ } if (ctx->Color.DitherFlag == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.DitherFlag = state; break; case GL_FOG: if (ctx->Fog.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); ctx->Fog.Enabled = state; break; case GL_HISTOGRAM: CHECK_EXTENSION(EXT_histogram, cap); if (ctx->Pixel.HistogramEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.HistogramEnabled = state; break; case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: case GL_LIGHT3: case GL_LIGHT4: case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; if (state) { insert_at_tail(&ctx->Light.EnabledList, &ctx->Light.Light[cap-GL_LIGHT0]); } else { remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); } break; case GL_LIGHTING: if (ctx->Light.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Enabled = state; if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; else ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; break; case GL_LINE_SMOOTH: if (ctx->Line.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.SmoothFlag = state; ctx->_TriangleCaps ^= DD_LINE_SMOOTH; break; case GL_LINE_STIPPLE: if (ctx->Line.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.StippleFlag = state; ctx->_TriangleCaps ^= DD_LINE_STIPPLE; break; case GL_INDEX_LOGIC_OP: if (ctx->Color.IndexLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.IndexLogicOpEnabled = state; break; case GL_COLOR_LOGIC_OP: if (ctx->Color.ColorLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.ColorLogicOpEnabled = state; break; case GL_MAP1_COLOR_4: if (ctx->Eval.Map1Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Color4 = state; break; case GL_MAP1_INDEX: if (ctx->Eval.Map1Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Index = state; break; case GL_MAP1_NORMAL: if (ctx->Eval.Map1Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Normal = state; break; case GL_MAP1_TEXTURE_COORD_1: if (ctx->Eval.Map1TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord1 = state; break; case GL_MAP1_TEXTURE_COORD_2: if (ctx->Eval.Map1TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord2 = state; break; case GL_MAP1_TEXTURE_COORD_3: if (ctx->Eval.Map1TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord3 = state; break; case GL_MAP1_TEXTURE_COORD_4: if (ctx->Eval.Map1TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord4 = state; break; case GL_MAP1_VERTEX_3: if (ctx->Eval.Map1Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex3 = state; break; case GL_MAP1_VERTEX_4: if (ctx->Eval.Map1Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex4 = state; break; case GL_MAP2_COLOR_4: if (ctx->Eval.Map2Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Color4 = state; break; case GL_MAP2_INDEX: if (ctx->Eval.Map2Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Index = state; break; case GL_MAP2_NORMAL: if (ctx->Eval.Map2Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Normal = state; break; case GL_MAP2_TEXTURE_COORD_1: if (ctx->Eval.Map2TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord1 = state; break; case GL_MAP2_TEXTURE_COORD_2: if (ctx->Eval.Map2TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord2 = state; break; case GL_MAP2_TEXTURE_COORD_3: if (ctx->Eval.Map2TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord3 = state; break; case GL_MAP2_TEXTURE_COORD_4: if (ctx->Eval.Map2TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord4 = state; break; case GL_MAP2_VERTEX_3: if (ctx->Eval.Map2Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex3 = state; break; case GL_MAP2_VERTEX_4: if (ctx->Eval.Map2Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex4 = state; break; case GL_MINMAX: if (ctx->Pixel.MinMaxEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.MinMaxEnabled = state; break; case GL_NORMALIZE: if (ctx->Transform.Normalize == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.Normalize = state; break; case GL_POINT_SMOOTH: if (ctx->Point.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.SmoothFlag = state; ctx->_TriangleCaps ^= DD_POINT_SMOOTH; break; case GL_POLYGON_SMOOTH: if (ctx->Polygon.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.SmoothFlag = state; ctx->_TriangleCaps ^= DD_TRI_SMOOTH; break; case GL_POLYGON_STIPPLE: if (ctx->Polygon.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.StippleFlag = state; ctx->_TriangleCaps ^= DD_TRI_STIPPLE; break; case GL_POLYGON_OFFSET_POINT: if (ctx->Polygon.OffsetPoint == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetPoint = state; break; case GL_POLYGON_OFFSET_LINE: if (ctx->Polygon.OffsetLine == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetLine = state; break; case GL_POLYGON_OFFSET_FILL: /*case GL_POLYGON_OFFSET_EXT:*/ if (ctx->Polygon.OffsetFill == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetFill = state; break; case GL_RESCALE_NORMAL_EXT: if (ctx->Transform.RescaleNormals == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RescaleNormals = state; break; case GL_SCISSOR_TEST: if (ctx->Scissor.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_SCISSOR); ctx->Scissor.Enabled = state; break; case GL_SHARED_TEXTURE_PALETTE_EXT: if (ctx->Texture.SharedPalette == state) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); ctx->Texture.SharedPalette = state; break; case GL_STENCIL_TEST: if (ctx->Stencil.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.Enabled = state; break; case GL_TEXTURE_1D: if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { return; } break; case GL_TEXTURE_2D: if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { return; } break; case GL_TEXTURE_3D: if (!enable_texture(ctx, state, TEXTURE_3D_BIT)) { return; } break; case GL_TEXTURE_GEN_Q: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT; if (state) newenabled |= Q_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; case GL_TEXTURE_GEN_R: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT; if (state) newenabled |= R_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; case GL_TEXTURE_GEN_S: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT; if (state) newenabled |= S_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; case GL_TEXTURE_GEN_T: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT; if (state) newenabled |= T_BIT; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; /* * CLIENT STATE!!! */ case GL_VERTEX_ARRAY: case GL_NORMAL_ARRAY: case GL_COLOR_ARRAY: case GL_INDEX_ARRAY: case GL_TEXTURE_COORD_ARRAY: case GL_EDGE_FLAG_ARRAY: case GL_FOG_COORDINATE_ARRAY_EXT: case GL_SECONDARY_COLOR_ARRAY_EXT: case GL_POINT_SIZE_ARRAY_OES: client_state( ctx, cap, state ); return; /* GL_SGI_color_table */ case GL_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); if (ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.ColorTableEnabled[COLORTABLE_PRECONVOLUTION] = state; break; case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCONVOLUTION] = state; break; case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_color_table, cap); if (ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.ColorTableEnabled[COLORTABLE_POSTCOLORMATRIX] = state; break; case GL_TEXTURE_COLOR_TABLE_SGI: CHECK_EXTENSION(SGI_texture_color_table, cap); if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state; break; /* GL_EXT_convolution */ case GL_CONVOLUTION_1D: CHECK_EXTENSION(EXT_convolution, cap); if (ctx->Pixel.Convolution1DEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.Convolution1DEnabled = state; break; case GL_CONVOLUTION_2D: CHECK_EXTENSION(EXT_convolution, cap); if (ctx->Pixel.Convolution2DEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.Convolution2DEnabled = state; break; case GL_SEPARABLE_2D: CHECK_EXTENSION(EXT_convolution, cap); if (ctx->Pixel.Separable2DEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PIXEL); ctx->Pixel.Separable2DEnabled = state; break; /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map, cap); if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { return; } break; /* GL_EXT_secondary_color */ case GL_COLOR_SUM_EXT: CHECK_EXTENSION2(EXT_secondary_color, ARB_vertex_program, cap); if (ctx->Fog.ColorSumEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); ctx->Fog.ColorSumEnabled = state; break; /* GL_ARB_multisample */ case GL_MULTISAMPLE_ARB: if (ctx->Multisample.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.Enabled = state; break; case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: if (ctx->Multisample.SampleAlphaToCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToCoverage = state; break; case GL_SAMPLE_ALPHA_TO_ONE_ARB: if (ctx->Multisample.SampleAlphaToOne == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToOne = state; break; case GL_SAMPLE_COVERAGE_ARB: if (ctx->Multisample.SampleCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverage = state; break; case GL_SAMPLE_COVERAGE_INVERT_ARB: if (ctx->Multisample.SampleCoverageInvert == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverageInvert = state; break; /* GL_IBM_rasterpos_clip */ case GL_RASTER_POSITION_UNCLIPPED_IBM: CHECK_EXTENSION(IBM_rasterpos_clip, cap); if (ctx->Transform.RasterPositionUnclipped == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RasterPositionUnclipped = state; break; /* GL_NV_point_sprite */ case GL_POINT_SPRITE_NV: CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); if (ctx->Point.PointSprite == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.PointSprite = state; break; #if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program case GL_VERTEX_PROGRAM_ARB: CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); if (ctx->VertexProgram.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->VertexProgram.Enabled = state; break; case GL_VERTEX_PROGRAM_POINT_SIZE_ARB: CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); if (ctx->VertexProgram.PointSizeEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->VertexProgram.PointSizeEnabled = state; break; case GL_VERTEX_PROGRAM_TWO_SIDE_ARB: CHECK_EXTENSION2(ARB_vertex_program, NV_vertex_program, cap); if (ctx->VertexProgram.TwoSideEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->VertexProgram.TwoSideEnabled = state; break; #endif #if FEATURE_NV_vertex_program case GL_MAP1_VERTEX_ATTRIB0_4_NV: case GL_MAP1_VERTEX_ATTRIB1_4_NV: case GL_MAP1_VERTEX_ATTRIB2_4_NV: case GL_MAP1_VERTEX_ATTRIB3_4_NV: case GL_MAP1_VERTEX_ATTRIB4_4_NV: case GL_MAP1_VERTEX_ATTRIB5_4_NV: case GL_MAP1_VERTEX_ATTRIB6_4_NV: case GL_MAP1_VERTEX_ATTRIB7_4_NV: case GL_MAP1_VERTEX_ATTRIB8_4_NV: case GL_MAP1_VERTEX_ATTRIB9_4_NV: case GL_MAP1_VERTEX_ATTRIB10_4_NV: case GL_MAP1_VERTEX_ATTRIB11_4_NV: case GL_MAP1_VERTEX_ATTRIB12_4_NV: case GL_MAP1_VERTEX_ATTRIB13_4_NV: case GL_MAP1_VERTEX_ATTRIB14_4_NV: case GL_MAP1_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program, cap); { const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV); FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Attrib[map] = state; } break; case GL_MAP2_VERTEX_ATTRIB0_4_NV: case GL_MAP2_VERTEX_ATTRIB1_4_NV: case GL_MAP2_VERTEX_ATTRIB2_4_NV: case GL_MAP2_VERTEX_ATTRIB3_4_NV: case GL_MAP2_VERTEX_ATTRIB4_4_NV: case GL_MAP2_VERTEX_ATTRIB5_4_NV: case GL_MAP2_VERTEX_ATTRIB6_4_NV: case GL_MAP2_VERTEX_ATTRIB7_4_NV: case GL_MAP2_VERTEX_ATTRIB8_4_NV: case GL_MAP2_VERTEX_ATTRIB9_4_NV: case GL_MAP2_VERTEX_ATTRIB10_4_NV: case GL_MAP2_VERTEX_ATTRIB11_4_NV: case GL_MAP2_VERTEX_ATTRIB12_4_NV: case GL_MAP2_VERTEX_ATTRIB13_4_NV: case GL_MAP2_VERTEX_ATTRIB14_4_NV: case GL_MAP2_VERTEX_ATTRIB15_4_NV: CHECK_EXTENSION(NV_vertex_program, cap); { const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV); FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Attrib[map] = state; } break; #endif /* FEATURE_NV_vertex_program */ #if FEATURE_NV_fragment_program case GL_FRAGMENT_PROGRAM_NV: CHECK_EXTENSION(NV_fragment_program, cap); if (ctx->FragmentProgram.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->FragmentProgram.Enabled = state; break; #endif /* FEATURE_NV_fragment_program */ /* GL_NV_texture_rectangle */ case GL_TEXTURE_RECTANGLE_NV: CHECK_EXTENSION(NV_texture_rectangle, cap); if (!enable_texture(ctx, state, TEXTURE_RECT_BIT)) { return; } break; /* GL_EXT_stencil_two_side */ case GL_STENCIL_TEST_TWO_SIDE_EXT: CHECK_EXTENSION(EXT_stencil_two_side, cap); if (ctx->Stencil.TestTwoSide == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.TestTwoSide = state; if (state) { ctx->Stencil._BackFace = 2; ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL; } else { ctx->Stencil._BackFace = 1; ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL; } break; #if FEATURE_ARB_fragment_program case GL_FRAGMENT_PROGRAM_ARB: CHECK_EXTENSION(ARB_fragment_program, cap); if (ctx->FragmentProgram.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->FragmentProgram.Enabled = state; break; #endif /* FEATURE_ARB_fragment_program */ /* GL_EXT_depth_bounds_test */ case GL_DEPTH_BOUNDS_TEST_EXT: CHECK_EXTENSION(EXT_depth_bounds_test, cap); if (state && ctx->DrawBuffer->Visual.depthBits == 0) { _mesa_warning(ctx, "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer"); return; } if (ctx->Depth.BoundsTest == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.BoundsTest = state; break; #if FEATURE_ATI_fragment_shader case GL_FRAGMENT_SHADER_ATI: CHECK_EXTENSION(ATI_fragment_shader, cap); if (ctx->ATIFragmentShader.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_PROGRAM); ctx->ATIFragmentShader.Enabled = state; break; #endif /* GL_MESA_texture_array */ case GL_TEXTURE_1D_ARRAY_EXT: CHECK_EXTENSION(MESA_texture_array, cap); if (!enable_texture(ctx, state, TEXTURE_1D_ARRAY_BIT)) { return; } break; case GL_TEXTURE_2D_ARRAY_EXT: CHECK_EXTENSION(MESA_texture_array, cap); if (!enable_texture(ctx, state, TEXTURE_2D_ARRAY_BIT)) { return; } break; default: _mesa_error(ctx, GL_INVALID_ENUM, "%s(0x%x)", state ? "glEnable" : "glDisable", cap); return; } if (ctx->Driver.Enable) { ctx->Driver.Enable( ctx, cap, state ); } }
void PLAYERS::render_player( const NETOBJ_CHARACTER *prev_char, const NETOBJ_CHARACTER *player_char, const NETOBJ_PLAYER_INFO *prev_info, const NETOBJ_PLAYER_INFO *player_info ) { NETOBJ_CHARACTER prev; NETOBJ_CHARACTER player; prev = *prev_char; player = *player_char; NETOBJ_PLAYER_INFO info = *player_info; TEE_RENDER_INFO render_info = gameclient.clients[info.cid].render_info; // check for teamplay modes bool new_tick = gameclient.new_tick; // check for ninja if ( player.weapon == WEAPON_NINJA ) { // change the skin for the player to the ninja int skin = gameclient.skins->find("x_ninja"); if (skin != -1) { render_info.texture = gameclient.skins->get( skin )->org_texture; render_info.color_body = vec4( 1,1,1,1 ); render_info.color_feet = vec4( 1,1,1,1 ); } } // set size render_info.size = 64.0f; float intratick = client_intratick(); if(player.health < 0) // dont render dead players return; float angle = mix((float)prev.angle, (float)player.angle, intratick)/256.0f; //float angle = 0; // just use the direct input if it's local player we are rendering if(info.local && client_state() != CLIENTSTATE_DEMOPLAYBACK) angle = get_angle(gameclient.controls->mouse_pos); // use preditect players if needed if(info.local && config.cl_predict && client_state() != CLIENTSTATE_DEMOPLAYBACK) { if ( gameclient.snap.local_character && ( gameclient.snap.local_character->health >= 0 ) ) { // apply predicted results gameclient.predicted_char.write(&player); gameclient.predicted_prev_char.write(&prev); intratick = client_predintratick(); new_tick = gameclient.new_predicted_tick; } } vec2 direction = get_direction((int)(angle*256.0f)); vec2 position = mix(vec2(prev.x, prev.y), vec2(player.x, player.y), intratick); vec2 vel = mix(vec2(prev.vx/256.0f, prev.vy/256.0f), vec2(player.vx/256.0f, player.vy/256.0f), intratick); gameclient.flow->add(position, vel*100.0f, 10.0f); render_info.got_airjump = player.jumped&2?0:1; // detect events if(new_tick) { // detect air jump if(!render_info.got_airjump && !(prev.jumped&2)) gameclient.effects->air_jump(position); } if(prev.health < 0) // Don't flicker from previous position position = vec2(player.x, player.y); bool stationary = player.vx < 1 && player.vx > -1; bool inair = col_check_point(player.x, player.y+16) == 0; bool want_other_dir = (player.direction == -1 && vel.x > 0) || (player.direction == 1 && vel.x < 0); // evaluate animation float walk_time = fmod(position.x, 100.0f)/100.0f; ANIMSTATE state; state.set(&data->animations[ANIM_BASE], 0); if(inair) state.add(&data->animations[ANIM_INAIR], 0, 1.0f); // TODO: some sort of time here else if(stationary) state.add(&data->animations[ANIM_IDLE], 0, 1.0f); // TODO: some sort of time here else if(!want_other_dir) state.add(&data->animations[ANIM_WALK], walk_time, 1.0f); if (player.weapon == WEAPON_HAMMER) { float ct = (client_prevtick()-player.attacktick)/(float)SERVER_TICK_SPEED + client_ticktime(); state.add(&data->animations[ANIM_HAMMER_SWING], clamp(ct*5.0f,0.0f,1.0f), 1.0f); } if (player.weapon == WEAPON_NINJA) { float ct = (client_prevtick()-player.attacktick)/(float)SERVER_TICK_SPEED + client_ticktime(); state.add(&data->animations[ANIM_NINJA_SWING], clamp(ct*2.0f,0.0f,1.0f), 1.0f); } // do skidding if(!inair && want_other_dir && length(vel*50) > 500.0f) { static int64 skid_sound_time = 0; if(time_get()-skid_sound_time > time_freq()/10) { gameclient.sounds->play(SOUNDS::CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, position); skid_sound_time = time_get(); } gameclient.effects->skidtrail( position+vec2(-player.direction*6,12), vec2(-player.direction*100*length(vel),-50) ); } // draw hook if (prev.hook_state>0 && player.hook_state>0) { gfx_texture_set(data->images[IMAGE_GAME].id); gfx_quads_begin(); //gfx_quads_begin(); vec2 pos = position; vec2 hook_pos; if(player_char->hooked_player != -1) { if(gameclient.snap.local_info && player_char->hooked_player == gameclient.snap.local_info->cid) { hook_pos = mix(vec2(gameclient.predicted_prev_char.pos.x, gameclient.predicted_prev_char.pos.y), vec2(gameclient.predicted_char.pos.x, gameclient.predicted_char.pos.y), client_predintratick()); } else hook_pos = mix(vec2(prev_char->hook_x, prev_char->hook_y), vec2(player_char->hook_x, player_char->hook_y), client_intratick()); } else hook_pos = mix(vec2(prev.hook_x, prev.hook_y), vec2(player.hook_x, player.hook_y), intratick); float d = distance(pos, hook_pos); vec2 dir = normalize(pos-hook_pos); gfx_quads_setrotation(get_angle(dir)+pi); // render head select_sprite(SPRITE_HOOK_HEAD); gfx_quads_draw(hook_pos.x, hook_pos.y, 24,16); // render chain select_sprite(SPRITE_HOOK_CHAIN); int i = 0; for(float f = 24; f < d && i < 1024; f += 24, i++) { vec2 p = hook_pos + dir*f; gfx_quads_draw(p.x, p.y,24,16); } gfx_quads_setrotation(0); gfx_quads_end(); render_hand(&render_info, position, normalize(hook_pos-pos), -pi/2, vec2(20, 0)); } // draw gun { gfx_texture_set(data->images[IMAGE_GAME].id); gfx_quads_begin(); gfx_quads_setrotation(state.attach.angle*pi*2+angle); // normal weapons int iw = clamp(player.weapon, 0, NUM_WEAPONS-1); select_sprite(data->weapons.id[iw].sprite_body, direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0); vec2 dir = direction; float recoil = 0.0f; vec2 p; if (player.weapon == WEAPON_HAMMER) { // Static position for hammer p = position + vec2(state.attach.x, state.attach.y); p.y += data->weapons.id[iw].offsety; // if attack is under way, bash stuffs if(direction.x < 0) { gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2); p.x -= data->weapons.id[iw].offsetx; } else { gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2); } draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); } else if (player.weapon == WEAPON_NINJA) { p = position; p.y += data->weapons.id[iw].offsety; if(direction.x < 0) { gfx_quads_setrotation(-pi/2-state.attach.angle*pi*2); p.x -= data->weapons.id[iw].offsetx; gameclient.effects->powerupshine(p+vec2(32,0), vec2(32,12)); } else { gfx_quads_setrotation(-pi/2+state.attach.angle*pi*2); gameclient.effects->powerupshine(p-vec2(32,0), vec2(32,12)); } draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); // HADOKEN if ((client_tick()-player.attacktick) <= (SERVER_TICK_SPEED / 6) && data->weapons.id[iw].num_sprite_muzzles) { int itex = rand() % data->weapons.id[iw].num_sprite_muzzles; float alpha = 1.0f; if (alpha > 0.0f && data->weapons.id[iw].sprite_muzzles[itex]) { vec2 dir = vec2(player_char->x,player_char->y) - vec2(prev_char->x, prev_char->y); dir = normalize(dir); float hadokenangle = get_angle(dir); gfx_quads_setrotation(hadokenangle); //float offsety = -data->weapons[iw].muzzleoffsety; select_sprite(data->weapons.id[iw].sprite_muzzles[itex], 0); vec2 diry(-dir.y,dir.x); p = position; float offsetx = data->weapons.id[iw].muzzleoffsetx; p -= dir * offsetx; draw_sprite(p.x, p.y, 160.0f); } } } else { // TODO: should be an animation recoil = 0; float a = (client_tick()-player.attacktick+intratick)/5.0f; if(a < 1) recoil = sinf(a*pi); p = position + dir * data->weapons.id[iw].offsetx - dir*recoil*10.0f; p.y += data->weapons.id[iw].offsety; draw_sprite(p.x, p.y, data->weapons.id[iw].visual_size); } if (player.weapon == WEAPON_GUN || player.weapon == WEAPON_SHOTGUN) { // check if we're firing stuff if(data->weapons.id[iw].num_sprite_muzzles)//prev.attackticks) { float alpha = 0.0f; int phase1tick = (client_tick() - player.attacktick); if (phase1tick < (data->weapons.id[iw].muzzleduration + 3)) { float t = ((((float)phase1tick) + intratick)/(float)data->weapons.id[iw].muzzleduration); alpha = LERP(2.0, 0.0f, min(1.0f,max(0.0f,t))); } int itex = rand() % data->weapons.id[iw].num_sprite_muzzles; if (alpha > 0.0f && data->weapons.id[iw].sprite_muzzles[itex]) { float offsety = -data->weapons.id[iw].muzzleoffsety; select_sprite(data->weapons.id[iw].sprite_muzzles[itex], direction.x < 0 ? SPRITE_FLAG_FLIP_Y : 0); if(direction.x < 0) offsety = -offsety; vec2 diry(-dir.y,dir.x); vec2 muzzlepos = p + dir * data->weapons.id[iw].muzzleoffsetx + diry * offsety; draw_sprite(muzzlepos.x, muzzlepos.y, data->weapons.id[iw].visual_size); } } } gfx_quads_end(); switch (player.weapon) { case WEAPON_GUN: render_hand(&render_info, p, direction, -3*pi/4, vec2(-15, 4)); break; case WEAPON_SHOTGUN: render_hand(&render_info, p, direction, -pi/2, vec2(-5, 4)); break; case WEAPON_GRENADE: render_hand(&render_info, p, direction, -pi/2, vec2(-4, 7)); break; } } // render the "shadow" tee if(info.local && config.debug) { vec2 ghost_position = mix(vec2(prev_char->x, prev_char->y), vec2(player_char->x, player_char->y), client_intratick()); TEE_RENDER_INFO ghost = render_info; ghost.color_body.a = 0.5f; ghost.color_feet.a = 0.5f; render_tee(&state, &ghost, player.emote, direction, ghost_position); // render ghost } render_info.size = 64.0f; // force some settings render_info.color_body.a = 1.0f; render_info.color_feet.a = 1.0f; render_tee(&state, &render_info, player.emote, direction, position); if(player.player_state == PLAYERSTATE_CHATTING) { gfx_texture_set(data->images[IMAGE_EMOTICONS].id); gfx_quads_begin(); select_sprite(SPRITE_DOTDOT); gfx_quads_draw(position.x + 24, position.y - 40, 64,64); gfx_quads_end(); } if (gameclient.clients[info.cid].emoticon_start != -1 && gameclient.clients[info.cid].emoticon_start + 2 * client_tickspeed() > client_tick()) { gfx_texture_set(data->images[IMAGE_EMOTICONS].id); gfx_quads_begin(); int since_start = client_tick() - gameclient.clients[info.cid].emoticon_start; int from_end = gameclient.clients[info.cid].emoticon_start + 2 * client_tickspeed() - client_tick(); float a = 1; if (from_end < client_tickspeed() / 5) a = from_end / (client_tickspeed() / 5.0); float h = 1; if (since_start < client_tickspeed() / 10) h = since_start / (client_tickspeed() / 10.0); float wiggle = 0; if (since_start < client_tickspeed() / 5) wiggle = since_start / (client_tickspeed() / 5.0); float wiggle_angle = sin(5*wiggle); gfx_quads_setrotation(pi/6*wiggle_angle); gfx_setcolor(1.0f,1.0f,1.0f,a); // client_datas::emoticon is an offset from the first emoticon select_sprite(SPRITE_OOP + gameclient.clients[info.cid].emoticon); gfx_quads_draw(position.x, position.y - 23 - 32*h, 64, 64*h); gfx_quads_end(); } }
/** * Helper function to enable or disable state. * * \param ctx GL context. * \param cap the state to enable/disable * \param state whether to enable or disable the specified capability. * * Updates the current context and flushes the vertices as needed. For * capabilities associated with extensions it verifies that those extensions * are effectivly present before updating. Notifies the driver via * dd_function_table::Enable. */ void _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) { if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "%s %s (newstate is %x)\n", state ? "glEnable" : "glDisable", _mesa_lookup_enum_by_nr(cap), ctx->NewState); switch (cap) { case GL_ALPHA_TEST: if (ctx->Color.AlphaEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.AlphaEnabled = state; break; case GL_AUTO_NORMAL: if (ctx->Eval.AutoNormal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.AutoNormal = state; break; case GL_BLEND: { if (state != ctx->Color.BlendEnabled) { FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.BlendEnabled = state; } } break; #if FEATURE_userclip case GL_CLIP_DISTANCE0: case GL_CLIP_DISTANCE1: case GL_CLIP_DISTANCE2: case GL_CLIP_DISTANCE3: case GL_CLIP_DISTANCE4: case GL_CLIP_DISTANCE5: case GL_CLIP_DISTANCE6: case GL_CLIP_DISTANCE7: { const GLuint p = cap - GL_CLIP_DISTANCE0; if (p >= ctx->Const.MaxClipPlanes) goto invalid_enum_error; if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p)) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); if (state) { ctx->Transform.ClipPlanesEnabled |= (1 << p); _mesa_update_clip_plane(ctx, p); } else { ctx->Transform.ClipPlanesEnabled &= ~(1 << p); } } break; #endif case GL_COLOR_MATERIAL: if (ctx->Light.ColorMaterialEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); FLUSH_CURRENT(ctx, 0); ctx->Light.ColorMaterialEnabled = state; if (state) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR] ); } break; case GL_CULL_FACE: if (ctx->Polygon.CullFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.CullFlag = state; break; case GL_DEPTH_TEST: if (ctx->Depth.Test == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.Test = state; break; case GL_DITHER: if (ctx->Color.DitherFlag == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.DitherFlag = state; break; case GL_FOG: if (ctx->Fog.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_FOG); ctx->Fog.Enabled = state; break; case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: case GL_LIGHT3: case GL_LIGHT4: case GL_LIGHT5: case GL_LIGHT6: case GL_LIGHT7: if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; if (state) { insert_at_tail(&ctx->Light.EnabledList, &ctx->Light.Light[cap-GL_LIGHT0]); } else { remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]); } break; case GL_LIGHTING: if (ctx->Light.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_LIGHT); ctx->Light.Enabled = state; if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE; else ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE; break; case GL_LINE_SMOOTH: if (ctx->Line.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.SmoothFlag = state; ctx->_TriangleCaps ^= DD_LINE_SMOOTH; break; case GL_LINE_STIPPLE: if (ctx->Line.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_LINE); ctx->Line.StippleFlag = state; ctx->_TriangleCaps ^= DD_LINE_STIPPLE; break; case GL_INDEX_LOGIC_OP: if (ctx->Color.IndexLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.IndexLogicOpEnabled = state; break; case GL_COLOR_LOGIC_OP: if (ctx->Color.ColorLogicOpEnabled == state) return; FLUSH_VERTICES(ctx, _NEW_COLOR); ctx->Color.ColorLogicOpEnabled = state; break; case GL_MAP1_COLOR_4: if (ctx->Eval.Map1Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Color4 = state; break; case GL_MAP1_INDEX: if (ctx->Eval.Map1Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Index = state; break; case GL_MAP1_NORMAL: if (ctx->Eval.Map1Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Normal = state; break; case GL_MAP1_TEXTURE_COORD_1: if (ctx->Eval.Map1TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord1 = state; break; case GL_MAP1_TEXTURE_COORD_2: if (ctx->Eval.Map1TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord2 = state; break; case GL_MAP1_TEXTURE_COORD_3: if (ctx->Eval.Map1TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord3 = state; break; case GL_MAP1_TEXTURE_COORD_4: if (ctx->Eval.Map1TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1TextureCoord4 = state; break; case GL_MAP1_VERTEX_3: if (ctx->Eval.Map1Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex3 = state; break; case GL_MAP1_VERTEX_4: if (ctx->Eval.Map1Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map1Vertex4 = state; break; case GL_MAP2_COLOR_4: if (ctx->Eval.Map2Color4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Color4 = state; break; case GL_MAP2_INDEX: if (ctx->Eval.Map2Index == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Index = state; break; case GL_MAP2_NORMAL: if (ctx->Eval.Map2Normal == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Normal = state; break; case GL_MAP2_TEXTURE_COORD_1: if (ctx->Eval.Map2TextureCoord1 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord1 = state; break; case GL_MAP2_TEXTURE_COORD_2: if (ctx->Eval.Map2TextureCoord2 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord2 = state; break; case GL_MAP2_TEXTURE_COORD_3: if (ctx->Eval.Map2TextureCoord3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord3 = state; break; case GL_MAP2_TEXTURE_COORD_4: if (ctx->Eval.Map2TextureCoord4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2TextureCoord4 = state; break; case GL_MAP2_VERTEX_3: if (ctx->Eval.Map2Vertex3 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex3 = state; break; case GL_MAP2_VERTEX_4: if (ctx->Eval.Map2Vertex4 == state) return; FLUSH_VERTICES(ctx, _NEW_EVAL); ctx->Eval.Map2Vertex4 = state; break; case GL_NORMALIZE: if (ctx->Transform.Normalize == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.Normalize = state; break; case GL_POINT_SMOOTH: if (ctx->Point.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.SmoothFlag = state; ctx->_TriangleCaps ^= DD_POINT_SMOOTH; break; case GL_POLYGON_SMOOTH: if (ctx->Polygon.SmoothFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.SmoothFlag = state; ctx->_TriangleCaps ^= DD_TRI_SMOOTH; break; case GL_POLYGON_STIPPLE: if (ctx->Polygon.StippleFlag == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.StippleFlag = state; ctx->_TriangleCaps ^= DD_TRI_STIPPLE; break; case GL_POLYGON_OFFSET_POINT: if (ctx->Polygon.OffsetPoint == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetPoint = state; break; case GL_POLYGON_OFFSET_LINE: if (ctx->Polygon.OffsetLine == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetLine = state; break; case GL_POLYGON_OFFSET_FILL: if (ctx->Polygon.OffsetFill == state) return; FLUSH_VERTICES(ctx, _NEW_POLYGON); ctx->Polygon.OffsetFill = state; break; case GL_RESCALE_NORMAL_EXT: if (ctx->Transform.RescaleNormals == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RescaleNormals = state; break; case GL_SCISSOR_TEST: if (ctx->Scissor.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_SCISSOR); ctx->Scissor.Enabled = state; break; case GL_STENCIL_TEST: if (ctx->Stencil.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_STENCIL); ctx->Stencil.Enabled = state; break; case GL_TEXTURE_1D: if (!enable_texture(ctx, state, TEXTURE_1D_BIT)) { return; } break; case GL_TEXTURE_2D: if (!enable_texture(ctx, state, TEXTURE_2D_BIT)) { return; } break; case GL_TEXTURE_GEN_S: case GL_TEXTURE_GEN_T: case GL_TEXTURE_GEN_R: case GL_TEXTURE_GEN_Q: { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLbitfield coordBit = S_BIT << (cap - GL_TEXTURE_GEN_S); GLbitfield newenabled = texUnit->TexGenEnabled & ~coordBit; if (state) newenabled |= coordBit; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; #if FEATURE_ES1 case GL_TEXTURE_GEN_STR_OES: /* disable S, T, and R at the same time */ { struct gl_texture_unit *texUnit = get_texcoord_unit(ctx); if (texUnit) { GLuint newenabled = texUnit->TexGenEnabled & ~STR_BITS; if (state) newenabled |= STR_BITS; if (texUnit->TexGenEnabled == newenabled) return; FLUSH_VERTICES(ctx, _NEW_TEXTURE); texUnit->TexGenEnabled = newenabled; } } break; #endif /* client-side state */ case GL_VERTEX_ARRAY: case GL_NORMAL_ARRAY: case GL_COLOR_ARRAY: case GL_INDEX_ARRAY: case GL_TEXTURE_COORD_ARRAY: case GL_EDGE_FLAG_ARRAY: case GL_FOG_COORDINATE_ARRAY_EXT: case GL_SECONDARY_COLOR_ARRAY_EXT: case GL_POINT_SIZE_ARRAY_OES: client_state( ctx, cap, state ); return; /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: CHECK_EXTENSION(ARB_texture_cube_map, cap); if (!enable_texture(ctx, state, TEXTURE_CUBE_BIT)) { return; } break; /* GL_ARB_multisample */ case GL_MULTISAMPLE_ARB: if (ctx->Multisample.Enabled == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.Enabled = state; break; case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: if (ctx->Multisample.SampleAlphaToCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToCoverage = state; break; case GL_SAMPLE_ALPHA_TO_ONE_ARB: if (ctx->Multisample.SampleAlphaToOne == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleAlphaToOne = state; break; case GL_SAMPLE_COVERAGE_ARB: if (ctx->Multisample.SampleCoverage == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverage = state; break; case GL_SAMPLE_COVERAGE_INVERT_ARB: if (ctx->Multisample.SampleCoverageInvert == state) return; FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); ctx->Multisample.SampleCoverageInvert = state; break; /* GL_IBM_rasterpos_clip */ case GL_RASTER_POSITION_UNCLIPPED_IBM: CHECK_EXTENSION(IBM_rasterpos_clip, cap); if (ctx->Transform.RasterPositionUnclipped == state) return; FLUSH_VERTICES(ctx, _NEW_TRANSFORM); ctx->Transform.RasterPositionUnclipped = state; break; /* GL_NV_point_sprite */ case GL_POINT_SPRITE_NV: CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap); if (ctx->Point.PointSprite == state) return; FLUSH_VERTICES(ctx, _NEW_POINT); ctx->Point.PointSprite = state; break; /* GL_EXT_depth_bounds_test */ case GL_DEPTH_BOUNDS_TEST_EXT: CHECK_EXTENSION(EXT_depth_bounds_test, cap); if (ctx->Depth.BoundsTest == state) return; FLUSH_VERTICES(ctx, _NEW_DEPTH); ctx->Depth.BoundsTest = state; break; default: goto invalid_enum_error; } if (ctx->Driver.Enable) { ctx->Driver.Enable( ctx, cap, state ); } return; invalid_enum_error: _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", state ? "Enable" : "Disable", cap); }
int MENUS::render() { RECT screen = *ui_screen(); gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); static bool first = true; if(first) { if(config.ui_page == PAGE_INTERNET) client_serverbrowse_refresh(0); else if(config.ui_page == PAGE_LAN) client_serverbrowse_refresh(1); first = false; } if(client_state() == CLIENTSTATE_ONLINE) { color_tabbar_inactive = color_tabbar_inactive_ingame; color_tabbar_active = color_tabbar_active_ingame; } else { render_background(); color_tabbar_inactive = color_tabbar_inactive_outgame; color_tabbar_active = color_tabbar_active_outgame; } RECT tab_bar; RECT main_view; // some margin around the screen ui_margin(&screen, 10.0f, &screen); if(popup == POPUP_NONE) { // do tab bar ui_hsplit_t(&screen, 24.0f, &tab_bar, &main_view); ui_vmargin(&tab_bar, 20.0f, &tab_bar); render_menubar(tab_bar); // news is not implemented yet if(config.ui_page <= PAGE_NEWS || config.ui_page > PAGE_SETTINGS || (client_state() == CLIENTSTATE_OFFLINE && config.ui_page >= PAGE_GAME && config.ui_page <= PAGE_CALLVOTE)) { client_serverbrowse_refresh(BROWSETYPE_INTERNET); config.ui_page = PAGE_INTERNET; } // render current page if(client_state() != CLIENTSTATE_OFFLINE) { if(game_page == PAGE_GAME) render_game(main_view); else if(game_page == PAGE_SERVER_INFO) render_serverinfo(main_view); else if(game_page == PAGE_CALLVOTE) render_servercontrol(main_view); else if(game_page == PAGE_SETTINGS) render_settings(main_view); } else if(config.ui_page == PAGE_NEWS) render_news(main_view); else if(config.ui_page == PAGE_INTERNET) render_serverbrowser(main_view); else if(config.ui_page == PAGE_LAN) render_serverbrowser(main_view); else if(config.ui_page == PAGE_DEMOS) render_demolist(main_view); else if(config.ui_page == PAGE_FAVORITES) render_serverbrowser(main_view); else if(config.ui_page == PAGE_SETTINGS) render_settings(main_view); // else if(config.ui_page == PAGE_TEE-NG) // renger_settings(main_teeng); } else { // make sure that other windows doesn't do anything funnay! //ui_set_hot_item(0); //ui_set_active_item(0); char buf[128]; const char *title = ""; const char *extra_text = ""; const char *button_text = ""; int extra_align = 0; if(popup == POPUP_MESSAGE) { title = message_topic; extra_text = message_body; button_text = message_button; } else if(popup == POPUP_CONNECTING) { title = localize("Connecting to"); extra_text = config.ui_server_address; // TODO: query the client about the address button_text = localize("Abort"); if(client_mapdownload_totalsize() > 0) { title = localize("Downloading map"); str_format(buf, sizeof(buf), "%d/%d KiB", client_mapdownload_amount()/1024, client_mapdownload_totalsize()/1024); extra_text = buf; } } else if(popup == POPUP_DISCONNECTED) { title = localize("Disconnected"); extra_text = client_error_string(); button_text = localize("Ok"); extra_align = -1; } else if(popup == POPUP_PURE) { title = localize("Disconnected"); extra_text = localize("The server is running a non-standard tuning on a pure game type."); button_text = localize("Ok"); extra_align = -1; } else if(popup == POPUP_PASSWORD) { title = localize("Password Incorrect"); extra_text = client_error_string(); button_text = localize("Try again"); } else if(popup == POPUP_QUIT) { title = localize("Quit"); extra_text = localize("Are you sure that you want to quit?"); } else if(popup == POPUP_FIRST_LAUNCH) { title = localize("Welcome to Teeworlds"); extra_text = localize("As this is the first time you launch the game, please enter your nick name below. It's recommended that you check the settings to adjust them to your liking before joining a server."); button_text = localize("Ok"); extra_align = -1; } RECT box, part; box = screen; ui_vmargin(&box, 150.0f, &box); ui_hmargin(&box, 150.0f, &box); // render the box ui_draw_rect(&box, vec4(0,0,0,0.5f), CORNER_ALL, 15.0f); ui_hsplit_t(&box, 20.f, &part, &box); ui_hsplit_t(&box, 24.f, &part, &box); ui_do_label(&part, title, 24.f, 0); ui_hsplit_t(&box, 20.f, &part, &box); ui_hsplit_t(&box, 24.f, &part, &box); ui_vmargin(&part, 20.f, &part); if(extra_align == -1) ui_do_label(&part, extra_text, 20.f, -1, (int)part.w); else ui_do_label(&part, extra_text, 20.f, 0, -1); if(popup == POPUP_QUIT) { RECT yes, no; ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 80.0f, &part); ui_vsplit_mid(&part, &no, &yes); ui_vmargin(&yes, 20.0f, &yes); ui_vmargin(&no, 20.0f, &no); static int button_abort = 0; if(ui_do_button(&button_abort, localize("No"), 0, &no, ui_draw_menu_button, 0) || escape_pressed) popup = POPUP_NONE; static int button_tryagain = 0; if(ui_do_button(&button_tryagain, localize("Yes"), 0, &yes, ui_draw_menu_button, 0) || enter_pressed) client_quit(); } else if(popup == POPUP_PASSWORD) { RECT label, textbox, tryagain, abort; ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 80.0f, &part); ui_vsplit_mid(&part, &abort, &tryagain); ui_vmargin(&tryagain, 20.0f, &tryagain); ui_vmargin(&abort, 20.0f, &abort); static int button_abort = 0; if(ui_do_button(&button_abort, localize("Abort"), 0, &abort, ui_draw_menu_button, 0) || escape_pressed) { if(config.cl_autoconnect) config.cl_autoconnect == 0; else popup = POPUP_NONE; } static int button_tryagain = 0; if(ui_do_button(&button_tryagain, localize("Try again"), 0, &tryagain, ui_draw_menu_button, 0) || enter_pressed) { client_connect(config.ui_server_address); } ui_hsplit_b(&box, 60.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vsplit_l(&part, 60.0f, 0, &label); ui_vsplit_l(&label, 100.0f, 0, &textbox); ui_vsplit_l(&textbox, 20.0f, 0, &textbox); ui_vsplit_r(&textbox, 60.0f, &textbox, 0); ui_do_label(&label, localize("Password"), 20, -1); ui_do_edit_box(&config.password, &textbox, config.password, sizeof(config.password), 14.0f, true); } else if(popup == POPUP_FIRST_LAUNCH) { RECT label, textbox; ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 80.0f, &part); static int enter_button = 0; if(ui_do_button(&enter_button, localize("Enter"), 0, &part, ui_draw_menu_button, 0) || enter_pressed) popup = POPUP_NONE; ui_hsplit_b(&box, 40.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vsplit_l(&part, 60.0f, 0, &label); ui_vsplit_l(&label, 100.0f, 0, &textbox); ui_vsplit_l(&textbox, 20.0f, 0, &textbox); ui_vsplit_r(&textbox, 60.0f, &textbox, 0); ui_do_label(&label, localize("Nickname"), 20, -1); ui_do_edit_box(&config.player_name, &textbox, config.player_name, sizeof(config.player_name), 14.0f); } else { ui_hsplit_b(&box, 20.f, &box, &part); ui_hsplit_b(&box, 24.f, &box, &part); ui_vmargin(&part, 120.0f, &part); static int button = 0; if(ui_do_button(&button, button_text, 0, &part, ui_draw_menu_button, 0) || escape_pressed || enter_pressed) { if(popup == POPUP_CONNECTING) client_disconnect(); popup = POPUP_NONE; } } } return 0; }
int MENUS::render_menubar(RECT r) { RECT box = r; RECT button; int active_page = config.ui_page; int new_page = -1; if(client_state() != CLIENTSTATE_OFFLINE) active_page = game_page; if(client_state() == CLIENTSTATE_OFFLINE) { /* offline menus */ if(0) // this is not done yet { ui_vsplit_l(&box, 90.0f, &button, &box); static int news_button=0; if (ui_do_button(&news_button, localize("News"), active_page==PAGE_NEWS, &button, ui_draw_menu_tab_button, 0)) new_page = PAGE_NEWS; ui_vsplit_l(&box, 30.0f, 0, &box); } ui_vsplit_l(&box, 100.0f, &button, &box); static int internet_button=0; int corners = CORNER_TL; if (ui_do_button(&internet_button, localize("Internet"), active_page==PAGE_INTERNET, &button, ui_draw_menu_tab_button, &corners)) { client_serverbrowse_refresh(BROWSETYPE_INTERNET); new_page = PAGE_INTERNET; } //ui_vsplit_l(&box, 4.0f, 0, &box); ui_vsplit_l(&box, 80.0f, &button, &box); static int lan_button=0; corners = 0; if (ui_do_button(&lan_button, localize("LAN"), active_page==PAGE_LAN, &button, ui_draw_menu_tab_button, &corners)) { client_serverbrowse_refresh(BROWSETYPE_LAN); new_page = PAGE_LAN; } //ui_vsplit_l(&box, 4.0f, 0, &box); ui_vsplit_l(&box, 110.0f, &button, &box); static int favorites_button=0; corners = CORNER_TR; if (ui_do_button(&favorites_button, localize("Favorites"), active_page==PAGE_FAVORITES, &button, ui_draw_menu_tab_button, &corners)) { client_serverbrowse_refresh(BROWSETYPE_FAVORITES); new_page = PAGE_FAVORITES; } ui_vsplit_l(&box, 4.0f*5, 0, &box); ui_vsplit_l(&box, 100.0f, &button, &box); static int demos_button=0; if (ui_do_button(&demos_button, localize("Demos"), active_page==PAGE_DEMOS, &button, ui_draw_menu_tab_button, 0)) { demolist_populate(); new_page = PAGE_DEMOS; } } else { /* online menus */ ui_vsplit_l(&box, 90.0f, &button, &box); static int game_button=0; if (ui_do_button(&game_button, localize("Game"), active_page==PAGE_GAME, &button, ui_draw_menu_tab_button, 0)) new_page = PAGE_GAME; ui_vsplit_l(&box, 4.0f, 0, &box); ui_vsplit_l(&box, 140.0f, &button, &box); static int server_info_button=0; if (ui_do_button(&server_info_button, localize("Server info"), active_page==PAGE_SERVER_INFO, &button, ui_draw_menu_tab_button, 0)) new_page = PAGE_SERVER_INFO; ui_vsplit_l(&box, 4.0f, 0, &box); ui_vsplit_l(&box, 140.0f, &button, &box); static int callvote_button=0; if (ui_do_button(&callvote_button, localize("Call vote"), active_page==PAGE_CALLVOTE, &button, ui_draw_menu_tab_button, 0)) new_page = PAGE_CALLVOTE; ui_vsplit_l(&box, 30.0f, 0, &box); } /* ui_vsplit_r(&box, 110.0f, &box, &button); static int system_button=0; if (ui_do_button(&system_button, "System", config.ui_page==PAGE_SYSTEM, &button, ui_draw_menu_tab_button, 0)) config.ui_page = PAGE_SYSTEM; ui_vsplit_r(&box, 30.0f, &box, 0); */ ui_vsplit_r(&box, 90.0f, &box, &button); static int quit_button=0; if (ui_do_button(&quit_button, localize("Quit"), 0, &button, ui_draw_menu_tab_button, 0)) popup = POPUP_QUIT; ui_vsplit_r(&box, 10.0f, &box, &button); ui_vsplit_r(&box, 130.0f, &box, &button); static int settings_button=0; if (ui_do_button(&settings_button, localize("Settings"), active_page==PAGE_SETTINGS, &button, ui_draw_menu_tab_button, 0)) new_page = PAGE_SETTINGS; if(new_page != -1) { if(client_state() == CLIENTSTATE_OFFLINE) config.ui_page = new_page; else game_page = new_page; } return 0; }
void MENUS::on_render() { /* // text rendering test stuff render_background(); TEXT_CURSOR cursor; gfx_text_set_cursor(&cursor, 10, 10, 20, TEXTFLAG_RENDER); gfx_text_ex(&cursor, "ようこそ - ガイド", -1); gfx_text_set_cursor(&cursor, 10, 30, 15, TEXTFLAG_RENDER); gfx_text_ex(&cursor, "ようこそ - ガイド", -1); //gfx_texture_set(-1); gfx_quads_begin(); gfx_quads_drawTL(60, 60, 5000, 5000); gfx_quads_end(); return;*/ if(client_state() != CLIENTSTATE_ONLINE && client_state() != CLIENTSTATE_DEMOPLAYBACK) set_active(true); if(client_state() == CLIENTSTATE_DEMOPLAYBACK) { RECT screen = *ui_screen(); gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); render_demoplayer(screen); } if(client_state() == CLIENTSTATE_ONLINE && gameclient.servermode == gameclient.SERVERMODE_PUREMOD) { client_disconnect(); set_active(true); popup = POPUP_PURE; } if(!is_active()) { escape_pressed = false; enter_pressed = false; num_inputevents = 0; return; } // update colors vec3 rgb = hsl_to_rgb(vec3(config.ui_color_hue/255.0f, config.ui_color_sat/255.0f, config.ui_color_lht/255.0f)); gui_color = vec4(rgb.r, rgb.g, rgb.b, config.ui_color_alpha/255.0f); color_tabbar_inactive_outgame = vec4(0,0,0,0.25f); color_tabbar_active_outgame = vec4(0,0,0,0.5f); float color_ingame_scale_i = 0.5f; float color_ingame_scale_a = 0.2f; color_tabbar_inactive_ingame = vec4( gui_color.r*color_ingame_scale_i, gui_color.g*color_ingame_scale_i, gui_color.b*color_ingame_scale_i, gui_color.a*0.8f); color_tabbar_active_ingame = vec4( gui_color.r*color_ingame_scale_a, gui_color.g*color_ingame_scale_a, gui_color.b*color_ingame_scale_a, gui_color.a); // update the ui RECT *screen = ui_screen(); float mx = (mouse_pos.x/(float)gfx_screenwidth())*screen->w; float my = (mouse_pos.y/(float)gfx_screenheight())*screen->h; int buttons = 0; if(inp_key_pressed(KEY_MOUSE_1)) buttons |= 1; if(inp_key_pressed(KEY_MOUSE_2)) buttons |= 2; if(inp_key_pressed(KEY_MOUSE_3)) buttons |= 4; ui_update(mx,my,mx*3.0f,my*3.0f,buttons); // render if(client_state() != CLIENTSTATE_DEMOPLAYBACK) render(); // render cursor gfx_texture_set(data->images[IMAGE_CURSOR].id); gfx_quads_begin(); gfx_setcolor(1,1,1,1); gfx_quads_drawTL(mx,my,24,24); gfx_quads_end(); // render debug information if(config.debug) { RECT screen = *ui_screen(); gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); char buf[512]; str_format(buf, sizeof(buf), "%p %p %p", ui_hot_item(), ui_active_item(), ui_last_active_item()); TEXT_CURSOR cursor; gfx_text_set_cursor(&cursor, 10, 10, 10, TEXTFLAG_RENDER); gfx_text_ex(&cursor, buf, -1); } escape_pressed = false; enter_pressed = false; num_inputevents = 0; }
/************************************************************************** Main handler for key presses **************************************************************************/ static Uint16 main_key_down_handler(SDL_keysym Key, void *pData) { static struct widget *pWidget; if ((pWidget = find_next_widget_for_key(NULL, Key)) != NULL) { return widget_pressed_action(pWidget); } else { if (Key.sym == SDLK_TAB) { /* input */ popup_input_line(); } else { if (map_event_handler(Key) && C_S_RUNNING == client_state()) { switch (Key.sym) { case SDLK_RETURN: case SDLK_KP_ENTER: if (LSHIFT || RSHIFT) { disable_focus_animation(); key_end_turn(); } else { struct unit *pUnit; struct city *pCity; if (NULL != (pUnit = head_of_units_in_focus()) && (pCity = tile_city(unit_tile(pUnit))) != NULL && city_owner(pCity) == client.conn.playing) { popup_city_dialog(pCity); } } return ID_ERROR; case SDLK_F2: units_report_dialog_popup(FALSE); return ID_ERROR; case SDLK_F4: city_report_dialog_popup(FALSE); return ID_ERROR; case SDLK_F7: send_report_request(REPORT_WONDERS_OF_THE_WORLD); return ID_ERROR; case SDLK_F8: send_report_request(REPORT_TOP_5_CITIES); return ID_ERROR; case SDLK_F9: if (meswin_dialog_is_open()) { meswin_dialog_popdown(); } else { meswin_dialog_popup(TRUE); } flush_dirty(); return ID_ERROR; case SDLK_F11: send_report_request(REPORT_DEMOGRAPHIC); return ID_ERROR; case SDLK_F12: popup_spaceship_dialog(client.conn.playing); return ID_ERROR; default: return ID_ERROR; } } } } return ID_ERROR; }
void CONSOLE::on_render() { RECT screen = *ui_screen(); float console_max_height = screen.h*3/5.0f; float console_height; float progress = (time_now()-(state_change_end-state_change_duration))/float(state_change_duration); if (progress >= 1.0f) { if (console_state == CONSOLE_CLOSING) console_state = CONSOLE_CLOSED; else if (console_state == CONSOLE_OPENING) console_state = CONSOLE_OPEN; progress = 1.0f; } if (console_state == CONSOLE_CLOSED) return; if (console_state == CONSOLE_OPEN) inp_mouse_mode_absolute(); float console_height_scale; if (console_state == CONSOLE_OPENING) console_height_scale = console_scale_func(progress); else if (console_state == CONSOLE_CLOSING) console_height_scale = console_scale_func(1.0f-progress); else //if (console_state == CONSOLE_OPEN) console_height_scale = console_scale_func(1.0f); console_height = console_height_scale*console_max_height; gfx_mapscreen(screen.x, screen.y, screen.w, screen.h); // do console shadow gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolorvertex(0, 0,0,0, 0.5f); gfx_setcolorvertex(1, 0,0,0, 0.5f); gfx_setcolorvertex(2, 0,0,0, 0.0f); gfx_setcolorvertex(3, 0,0,0, 0.0f); gfx_quads_drawTL(0,console_height,screen.w,10.0f); gfx_quads_end(); // do background gfx_texture_set(data->images[IMAGE_CONSOLE_BG].id); gfx_quads_begin(); gfx_setcolor(0.2f, 0.2f, 0.2f,0.9f); if(console_type != 0) gfx_setcolor(0.4f, 0.2f, 0.2f,0.9f); gfx_quads_setsubset(0,-console_height*0.075f,screen.w*0.075f*0.5f,0); gfx_quads_drawTL(0,0,screen.w,console_height); gfx_quads_end(); // do small bar shadow gfx_texture_set(-1); gfx_quads_begin(); gfx_setcolorvertex(0, 0,0,0, 0.0f); gfx_setcolorvertex(1, 0,0,0, 0.0f); gfx_setcolorvertex(2, 0,0,0, 0.25f); gfx_setcolorvertex(3, 0,0,0, 0.25f); gfx_quads_drawTL(0,console_height-20,screen.w,10); gfx_quads_end(); // do the lower bar gfx_texture_set(data->images[IMAGE_CONSOLE_BAR].id); gfx_quads_begin(); gfx_setcolor(1.0f, 1.0f, 1.0f, 0.9f); gfx_quads_setsubset(0,0.1f,screen.w*0.015f,1-0.1f); gfx_quads_drawTL(0,console_height-10.0f,screen.w,10.0f); gfx_quads_end(); console_height -= 22.0f; INSTANCE *console = current_console(); { float font_size = 10.0f; float row_height = font_size*1.25f; float x = 3; float y = console_height - row_height - 2; // render prompt TEXT_CURSOR cursor; gfx_text_set_cursor(&cursor, x, y, font_size, TEXTFLAG_RENDER); RENDERINFO info; info.wanted_completion = console->completion_chosen; info.enum_count = 0; info.current_cmd = console->completion_buffer; gfx_text_set_cursor(&info.cursor, x, y+12.0f, font_size, TEXTFLAG_RENDER); const char *prompt = "> "; if(console_type) { if(client_state() == CLIENTSTATE_ONLINE) { if(client_rcon_authed()) prompt = "rcon> "; else prompt = "ENTER PASSWORD> "; } else prompt = "NOT CONNECTED> "; } gfx_text_ex(&cursor, prompt, -1); // render console input gfx_text_ex(&cursor, console->input.get_string(), console->input.cursor_offset()); TEXT_CURSOR marker = cursor; gfx_text_ex(&marker, "|", -1); gfx_text_ex(&cursor, console->input.get_string()+console->input.cursor_offset(), -1); // render version char buf[128]; str_format(buf, sizeof(buf), "v%s", GAME_VERSION); float version_width = gfx_text_width(0, font_size, buf, -1); gfx_text(0, screen.w-version_width-5, y, font_size, buf, -1); // render possible commands if(console->input.get_string()[0] != 0) { console_possible_commands(console->completion_buffer, console->completion_flagmask, possible_commands_render_callback, &info); if(info.enum_count <= 0) { if(console->command) { char buf[512]; str_format(buf, sizeof(buf), "Help: %s ", console->command->help); gfx_text_ex(&info.cursor, buf, -1); gfx_text_color(0.75f, 0.75f, 0.75f, 1); str_format(buf, sizeof(buf), "Syntax: %s %s", console->command->name, console->command->params); gfx_text_ex(&info.cursor, buf, -1); } } } gfx_text_color(1,1,1,1); // render log y -= row_height; char *entry = (char *)ringbuf_last(console->backlog); while (y > 0.0f && entry) { gfx_text(0, x, y, font_size, entry, -1); y -= row_height; entry = (char *)ringbuf_prev(console->backlog, entry); } } }