Exemplo n.º 1
0
	int32_t LuaGraphics::getBackgroundColor(lua_State *L)
	{
		auto graphics = Module::getInstance<Graphics>(ModuleType::GRAPHICS);
		auto color = graphics->getBackgroundColor();
		Lua::pushInteger(L, colorToInt(color));
		return 1;
	}
void ColorData::setImage(QImage* i){
    this->image = i;
    if (isTemplate){
        if (ColorData::s_templates.size() < 3){
            ColorData::s_templates.push_back(NULL);
            ColorData::s_templates.push_back(NULL);
            ColorData::s_templates.push_back(NULL);
        }
        ColorData::s_templates[colorToInt(color)] = new Template(*i, colorToTeam(color));
    }
}
Exemplo n.º 3
0
void GUI_TextField::Update(int force)
{
    if (!parent || !font) {
        return;
    }
    GUI_Widget::Update(force);
    if (force) {
        GUI_Surface *surface;
        SDL_Rect r = area;
        SDL_Rect clip = area;
        clip.x = clip.x + border.x;
        clip.y = clip.y + border.y;
        clip.w = clip.w - (border.x * 2);
        clip.h = clip.h - (border.y * 2);
        SDL_Color color = IsFocused() || IsInside() ? fontfocusedcolor : fontnormalcolor;
        // Draw text
        surface = font->RenderQuality(buffer, color);
        if (surface != NULL) {
            switch (align & ALIGN_HORIZ_MASK) {
             case ALIGN_HORIZ_CENTER:
                  if (surface->GetWidth() < r.w) {
                      r.x = r.x + (r.w - surface->GetWidth()) / 2;
                  }
                  break;
             case ALIGN_HORIZ_RIGHT:
                  if (surface->GetWidth() < r.w) {
                      r.x = r.x + r.w - surface->GetWidth();
                  }
                  break;
            }
            DrawClipped(surface, parent, clip, r.x + border.x - startoffset, r.y + ((r.h - surface->GetHeight()) / 2));
            surface->DecRef();
        }
        // Draw cursor
        if (IsFocused()) {
            strcpy(cbuffer, buffer);
            cbuffer[cursorpos] = 0;
            SDL_Rect textsize = font->GetTextSize(cbuffer);
            int cursorx = r.x + border.x + textsize.w - startoffset;
            surface = new GUI_Surface("cursor", SDL_SWSURFACE, 2, clip.h, 32, RMask, GMask, BMask, AMask);
            surface->Fill(NULL, colorToInt(color));
            DrawClipped(surface, parent, clip, cursorx, r.y + ((r.h - surface->GetHeight()) / 2));
            surface->DecRef();
        }
    }
}
Exemplo n.º 4
0
	int32_t LuaDrawable::getColor(lua_State *L)
	{
		auto drawable = Lua::getObject<Drawable>(L, 1, LuaType::Drawable);
		Lua::pushInteger(L, colorToInt(drawable->getColor()));
		return 1;
	}