mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Move color conversion functions to seperate header and add variables to customize editor colors
This commit is contained in:
parent
fee5f5ec9f
commit
a5debee342
|
@ -1,6 +1,7 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
|
||||
#include <base/color.h>
|
||||
#include <base/math.h>
|
||||
|
||||
#include <engine/engine.h>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <math.h>
|
||||
|
||||
#include <base/color.h>
|
||||
#include <base/system.h>
|
||||
#include <base/math.h>
|
||||
|
||||
|
|
|
@ -280,31 +280,6 @@ public:
|
|||
class CMapLayers *m_pMapLayersForeGround;
|
||||
};
|
||||
|
||||
|
||||
inline float HueToRgb(float v1, float v2, float h)
|
||||
{
|
||||
if(h < 0.0f) h += 1;
|
||||
if(h > 1.0f) h -= 1;
|
||||
if((6.0f * h) < 1.0f) return v1 + (v2 - v1) * 6.0f * h;
|
||||
if((2.0f * h) < 1.0f) return v2;
|
||||
if((3.0f * h) < 2.0f) return v1 + (v2 - v1) * ((2.0f/3.0f) - h) * 6.0f;
|
||||
return v1;
|
||||
}
|
||||
|
||||
inline vec3 HslToRgb(vec3 HSL)
|
||||
{
|
||||
if(HSL.s == 0.0f)
|
||||
return vec3(HSL.l, HSL.l, HSL.l);
|
||||
else
|
||||
{
|
||||
float v2 = HSL.l < 0.5f ? HSL.l * (1.0f + HSL.s) : (HSL.l+HSL.s) - (HSL.s*HSL.l);
|
||||
float v1 = 2.0f * HSL.l - v2;
|
||||
|
||||
return vec3(HueToRgb(v1, v2, HSL.h + (1.0f/3.0f)), HueToRgb(v1, v2, HSL.h), HueToRgb(v1, v2, HSL.h - (1.0f/3.0f)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern const char *Localize(const char *Str, const char *pContext="");
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
|
||||
#include <base/color.h>
|
||||
#include <base/system.h>
|
||||
|
||||
#include <engine/shared/datafile.h>
|
||||
|
@ -637,6 +638,7 @@ void CEditor::RenderGrid(CLayerGroup *pGroup)
|
|||
if(!m_GridActive)
|
||||
return;
|
||||
|
||||
vec4 gridColor;
|
||||
float aGroupPoints[4];
|
||||
pGroup->Mapping(aGroupPoints);
|
||||
|
||||
|
@ -656,18 +658,20 @@ void CEditor::RenderGrid(CLayerGroup *pGroup)
|
|||
for(int i = 0; i < (int)w; i++)
|
||||
{
|
||||
if((i+YGridOffset) % m_GridFactor == 0)
|
||||
Graphics()->SetColor(1.0f, 0.3f, 0.3f, 0.3f);
|
||||
gridColor = HexToRgba(g_Config.m_EdColorGridOuter);
|
||||
else
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.15f);
|
||||
gridColor = HexToRgba(g_Config.m_EdColorGridInner);
|
||||
|
||||
Graphics()->SetColor(gridColor.r, gridColor.g, gridColor.b, gridColor.a);
|
||||
IGraphics::CLineItem Line = IGraphics::CLineItem(LineDistance*XOffset, LineDistance*i+LineDistance*YOffset, w+aGroupPoints[2], LineDistance*i+LineDistance*YOffset);
|
||||
Graphics()->LinesDraw(&Line, 1);
|
||||
|
||||
if((i+XGridOffset) % m_GridFactor == 0)
|
||||
Graphics()->SetColor(1.0f, 0.3f, 0.3f, 0.3f);
|
||||
gridColor = HexToRgba(g_Config.m_EdColorGridOuter);
|
||||
else
|
||||
Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.15f);
|
||||
gridColor = HexToRgba(g_Config.m_EdColorGridInner);
|
||||
|
||||
Graphics()->SetColor(gridColor.r, gridColor.g, gridColor.b, gridColor.a);
|
||||
Line = IGraphics::CLineItem(LineDistance*i+LineDistance*XOffset, LineDistance*YOffset, LineDistance*i+LineDistance*XOffset, h+aGroupPoints[3]);
|
||||
Graphics()->LinesDraw(&Line, 1);
|
||||
}
|
||||
|
@ -1158,6 +1162,8 @@ void CEditor::DoQuad(CQuad *q, int Index)
|
|||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
}
|
||||
|
||||
vec4 pivotColor;
|
||||
|
||||
if(UI()->ActiveItem() == pID)
|
||||
{
|
||||
if(m_MouseDeltaWx*m_MouseDeltaWx+m_MouseDeltaWy*m_MouseDeltaWy > 0.5f)
|
||||
|
@ -1264,13 +1270,13 @@ void CEditor::DoQuad(CQuad *q, int Index)
|
|||
}
|
||||
}
|
||||
|
||||
Graphics()->SetColor(1,1,1,1);
|
||||
pivotColor = HexToRgba(g_Config.m_EdColorQuadPivotActive);
|
||||
}
|
||||
else if(UI()->HotItem() == pID)
|
||||
{
|
||||
ms_pUiGotContext = pID;
|
||||
|
||||
Graphics()->SetColor(1,1,1,1);
|
||||
pivotColor = HexToRgba(g_Config.m_EdColorQuadPivotHover);
|
||||
m_pTooltip = "Left mouse button to move. Hold shift to move pivot. Hold ctrl to rotate. Hold alt to ignore grid.";
|
||||
|
||||
if(UI()->MouseButton(0))
|
||||
|
@ -1308,8 +1314,9 @@ void CEditor::DoQuad(CQuad *q, int Index)
|
|||
}
|
||||
}
|
||||
else
|
||||
Graphics()->SetColor(0,1,0,1);
|
||||
pivotColor = HexToRgba(g_Config.m_EdColorQuadPivot);
|
||||
|
||||
Graphics()->SetColor(pivotColor.r, pivotColor.g, pivotColor.b, pivotColor.a);
|
||||
IGraphics::CQuadItem QuadItem(CenterX, CenterY, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom);
|
||||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
}
|
||||
|
@ -1354,6 +1361,8 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V)
|
|||
else
|
||||
IgnoreGrid = false;
|
||||
|
||||
vec4 pointColor;
|
||||
|
||||
if(UI()->ActiveItem() == pID)
|
||||
{
|
||||
float dx = m_MouseDeltaWx;
|
||||
|
@ -1442,13 +1451,13 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V)
|
|||
}
|
||||
}
|
||||
|
||||
Graphics()->SetColor(1,1,1,1);
|
||||
pointColor = HexToRgba(g_Config.m_EdColorQuadPointActive);
|
||||
}
|
||||
else if(UI()->HotItem() == pID)
|
||||
{
|
||||
ms_pUiGotContext = pID;
|
||||
|
||||
Graphics()->SetColor(1,1,1,1);
|
||||
pointColor = HexToRgba(g_Config.m_EdColorQuadPointHover);
|
||||
m_pTooltip = "Left mouse button to move. Hold shift to move the texture. Hold alt to ignore grid.";
|
||||
|
||||
if(UI()->MouseButton(0))
|
||||
|
@ -1490,8 +1499,9 @@ void CEditor::DoQuadPoint(CQuad *pQuad, int QuadIndex, int V)
|
|||
}
|
||||
}
|
||||
else
|
||||
Graphics()->SetColor(1,0,0,1);
|
||||
pointColor = HexToRgba(g_Config.m_EdColorQuadPoint);
|
||||
|
||||
Graphics()->SetColor(pointColor.r, pointColor.g, pointColor.b, pointColor.a);
|
||||
IGraphics::CQuadItem QuadItem(px, py, 5.0f*m_WorldZoom, 5.0f*m_WorldZoom);
|
||||
Graphics()->QuadsDraw(&QuadItem, 1);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <base/color.h>
|
||||
#include <base/math.h>
|
||||
|
||||
#include <engine/console.h>
|
||||
|
@ -80,6 +81,7 @@ CQuad *CLayerQuads::NewQuad()
|
|||
void CLayerQuads::BrushSelecting(CUIRect Rect)
|
||||
{
|
||||
// draw selection rectangle
|
||||
vec4 rectColor = HexToRgba(g_Config.m_EdColorSelectionQuad);
|
||||
IGraphics::CLineItem Array[4] = {
|
||||
IGraphics::CLineItem(Rect.x, Rect.y, Rect.x+Rect.w, Rect.y),
|
||||
IGraphics::CLineItem(Rect.x+Rect.w, Rect.y, Rect.x+Rect.w, Rect.y+Rect.h),
|
||||
|
@ -87,6 +89,7 @@ void CLayerQuads::BrushSelecting(CUIRect Rect)
|
|||
IGraphics::CLineItem(Rect.x, Rect.y+Rect.h, Rect.x, Rect.y)};
|
||||
Graphics()->TextureClear();
|
||||
Graphics()->LinesBegin();
|
||||
Graphics()->SetColor(rectColor.r, rectColor.g, rectColor.b, rectColor.a);
|
||||
Graphics()->LinesDraw(Array, 4);
|
||||
Graphics()->LinesEnd();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
||||
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
||||
#include <base/color.h>
|
||||
#include <base/math.h>
|
||||
|
||||
#include <engine/client.h>
|
||||
|
@ -123,9 +124,11 @@ void CLayerTiles::Clamp(RECTi *pRect)
|
|||
|
||||
void CLayerTiles::BrushSelecting(CUIRect Rect)
|
||||
{
|
||||
vec4 fillColor = HexToRgba(g_Config.m_EdColorSelectionTile);
|
||||
|
||||
Graphics()->TextureClear();
|
||||
m_pEditor->Graphics()->QuadsBegin();
|
||||
m_pEditor->Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.4f);
|
||||
m_pEditor->Graphics()->SetColor(fillColor.r, fillColor.g, fillColor.b, fillColor.a);
|
||||
Snap(&Rect);
|
||||
IGraphics::CQuadItem QuadItem(Rect.x, Rect.y, Rect.w, Rect.h);
|
||||
m_pEditor->Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
|
|
|
@ -30,6 +30,16 @@ MACRO_CONFIG_INT(ClCustomizeSkin, cl_customize_skin, 0, 0, 1, CFGFLAG_CLIENT|CFG
|
|||
|
||||
MACRO_CONFIG_INT(EdZoomTarget, ed_zoom_target, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Zoom to the current mouse target")
|
||||
MACRO_CONFIG_INT(EdShowkeys, ed_showkeys, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorGridInner, ed_color_grid_inner, 0xFFFFFF26, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorGridOuter, ed_color_grid_outer, 0xFF4C4C4C, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorQuadPoint, ed_color_quad_point, 0xFF0000FF, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorQuadPointHover, ed_color_quad_point_hover, 0xFFFFFFFF, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorQuadPointActive, ed_color_quad_point_active, 0xFFFFFFFF, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorQuadPivot, ed_color_quad_pivot, 0x00FF00FF, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorQuadPivotHover, ed_color_quad_pivot_hover, 0xFFFFFFFF, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorQuadPivotActive, ed_color_quad_pivot_Active, 0xFFFFFFFF, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorSelectionQuad, ed_color_selection_quad, 0xFFFFFFFF, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
MACRO_CONFIG_INT(EdColorSelectionTile, ed_color_selection_tile, 0xFFFFFF66, 0, 0, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
|
||||
//MACRO_CONFIG_INT(ClFlow, cl_flow, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "")
|
||||
|
||||
|
|
Loading…
Reference in a new issue