bool ETHBackBufferTargetManager::ComputeLength(gs2d::VideoPtr video, const gs2d::str_type::string& thisSide, const gs2d::str_type::string& otherSide, const bool isWidth) { if (IsAuto(thisSide)) { const gs2d::math::Vector2 screenSize(video->GetScreenSizeF()); if (IsAuto(otherSide)) { m_bufferSize = screenSize; return true; } else { float otherValue = -1.0f; GS2D_SSCANF(otherSide.c_str(), GS_L("%f"), &otherValue); if (isWidth) m_bufferSize.x = ceilf(otherValue * (screenSize.x / screenSize.y)); else m_bufferSize.y = ceilf(otherValue * (screenSize.y / screenSize.x)); return false; } } else { int value = -1; GS2D_SSCANF(thisSide.c_str(), GS_L("%i"), &value); if (isWidth) m_bufferSize.x = static_cast<float>(value); else m_bufferSize.y = static_cast<float>(value); return false; } }
ETHPolygon::ETHPolygon(const gs2d::str_type::string& enmlString) { gs2d::enml::File file(enmlString); gs2d::enml::Entity* entity; unsigned int v = 0; while ((entity = file.GetEntity(GetEntityName(v))) != 0) { const gs2d::str_type::string& Xvalue = entity->Get(GS_L("x")); const gs2d::str_type::string& Yvalue = entity->Get(GS_L("y")); float x = 0.0f, y = 0.0f; GS2D_SSCANF(Xvalue.c_str(), GS_L("%f"), &x); GS2D_SSCANF(Yvalue.c_str(), GS_L("%f"), &y); m_vertices.push_back(gs2d::math::Vector2(x, y)); ++v; } }
int GSGUI_INT_INPUT::PlaceInput(Vector2 v2Pos) { int r = 0; m_video->SetZBuffer(false); m_video->SetZWrite(false); Vector2 v2Size(m_width, m_size), v2TextAdd(m_size/4.0f, 0.0f); m_mouseOver = MouseOver(v2Pos, v2Size); Color top, bottom, text; if (m_active) { top = m_style.active_top; bottom = m_style.active_bottom; text = m_style.active_text; if (!m_mouseOver) { if (m_input->GetLeftClickState() == GSKS_HIT || m_input->GetRightClickState() == GSKS_HIT) m_active = false; } if (m_input->GetKeyState(GSK_ENTER) == GSKS_HIT) m_active = false; } else { if (m_mouseOver) { if (m_input->GetLeftClickState() == GSKS_HIT) m_active = true; top = m_style.focused_top; bottom = m_style.focused_bottom; text = m_style.active_text; } else { top = m_style.inactive_top; bottom = m_style.inactive_bottom; text = m_style.inactive_text; } if (m_strInput.GetString() == GS_L("")) m_strInput.SetString(GS_L("0")); } m_video->DrawRectangle(v2Pos, Vector2(m_width, m_size), top, top, bottom, bottom); str_type::stringstream ss; ss << m_strInput.GetString(); if (ss.str().length() > 0) //-V807 { GS2D_SSCANF(ss.str().c_str(), GS_L("%i"), &r); if (m_active && m_input->GetWheelState() != 0.0f) { r += (int)m_input->GetWheelState()*m_scrollAdd; ss.str(GS_L("")); ss << r; m_strInput.SetString(ss.str()); } GS2D_SSCANF(ss.str().c_str(), GS_L("%i"), &r); if (m_clamp) { if (r > m_max) { r = m_max; ss.str(GS_L("")); ss << r; } else if (r < m_min) { r = m_min; ss.str(GS_L("")); ss << r; } m_strInput.SetString(ss.str()); } } if (m_active) { m_strInput.PlaceInput(v2Pos+v2TextAdd, GS_L("Verdana14_shadow.fnt"), m_nMaxChars, m_size, text, m_video, m_input); } else { m_strInput.Place(v2Pos+v2TextAdd, GS_L("Verdana14_shadow.fnt"), m_size, text, m_video); } if (m_active || m_mouseOver) DrawOutline(v2Pos, v2Size); return r; }
float GSGUI_FLOAT_INPUT::PlaceInput(Vector2 v2Pos) { m_lastValue = 0; m_video->SetZBuffer(false); m_video->SetZWrite(false); Vector2 v2Size(m_width, m_size), v2TextAdd(m_size/4.0f, 0.0f); m_mouseOver = MouseOver(v2Pos+Vector2(m_width, 0.0f), v2Size); Color top, bottom, text; m_video->DrawBitmapText( v2Pos + v2TextAdd, m_text.c_str(), GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE ); if (m_active) { top = m_style.active_top; bottom = m_style.active_bottom; text = m_style.active_text; if (!m_mouseOver) { if (m_input->GetLeftClickState() == GSKS_HIT || m_input->GetRightClickState() == GSKS_HIT) m_active = false; } if (m_input->GetKeyState(GSK_ENTER) == GSKS_HIT) m_active = false; } else { if (m_mouseOver) { if (m_input->GetLeftClickState() == GSKS_HIT) m_active = true; top = m_style.focused_top; bottom = m_style.focused_bottom; text = m_style.active_text; } else { top = m_style.inactive_top; bottom = m_style.inactive_bottom; text = m_style.inactive_text; } if (m_strInput.GetString() == GS_L("")) m_strInput.SetString(GS_L("0.0")); } m_video->DrawRectangle(v2Pos+Vector2(m_width, 0.0f), Vector2(m_width, m_size), top, top, bottom, bottom); str_type::stringstream ss; ss.str(m_strInput.GetString()); // if there are no chars, go back to the min value //const unsigned int nLen = ss.str().length(); //-V807 if (m_strInput.GetString().length() > 0) { GS2D_SSCANF(ss.str().c_str(), GS_L("%f"), &m_lastValue); if (m_active && m_input->GetWheelState() != 0.0f) { m_lastValue += m_input->GetWheelState()*m_scrollAdd; ss.str(GS_L("")); ss << m_lastValue; m_strInput.SetString(ss.str()); } GS2D_SSCANF(ss.str().c_str(), GS_L("%f"), &m_lastValue); if (m_clamp) { if (m_lastValue > m_max) { m_lastValue = m_max; ss.str(GS_L("")); ss << m_lastValue; } else if (m_lastValue < m_min) { m_lastValue = m_min; ss.str(GS_L("")); ss << m_lastValue; } m_strInput.SetString(ss.str()); } } if (m_active) { m_strInput.PlaceInput(v2Pos+v2TextAdd+Vector2(m_width, 0.0f), GS_L("Verdana14_shadow.fnt"), m_nMaxChars, m_size, text, m_video, m_input); } else { m_strInput.Place(v2Pos+v2TextAdd+Vector2(m_width, 0.0f), GS_L("Verdana14_shadow.fnt"), m_size, text, m_video); } if (m_active || m_mouseOver) DrawOutline(v2Pos, v2Size+Vector2(m_width, 0.0f)); return m_lastValue; }