diff options
Diffstat (limited to 'src/game/editor')
| -rw-r--r-- | src/game/editor/ed_editor.cpp | 2 | ||||
| -rw-r--r-- | src/game/editor/ed_editor.h | 1 | ||||
| -rw-r--r-- | src/game/editor/ed_io.cpp | 14 | ||||
| -rw-r--r-- | src/game/editor/ed_layer_tiles.cpp | 29 |
4 files changed, 37 insertions, 9 deletions
diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index d8d72cc6..7195bd61 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1827,7 +1827,7 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) m_SelectedGroup = g; static int s_LayerPopupId = 0; if(Result == 2) - UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupLayer); + UiInvokePopupMenu(&s_LayerPopupId, 0, UI()->MouseX(), UI()->MouseY(), 120, 220, PopupLayer); } LayerCur += 14.0f; diff --git a/src/game/editor/ed_editor.h b/src/game/editor/ed_editor.h index 38532392..461cdeed 100644 --- a/src/game/editor/ed_editor.h +++ b/src/game/editor/ed_editor.h @@ -394,6 +394,7 @@ public: int m_Image; int m_Width; int m_Height; + CColor m_Color; CTile *m_pTiles; }; diff --git a/src/game/editor/ed_io.cpp b/src/game/editor/ed_io.cpp index cb914ad9..2eff397c 100644 --- a/src/game/editor/ed_io.cpp +++ b/src/game/editor/ed_io.cpp @@ -283,11 +283,11 @@ int CEditorMap::Save(class IStorage *pStorage, const char *pFileName) Item.m_Layer.m_Flags = pLayer->m_Flags; Item.m_Layer.m_Type = pLayer->m_Type; - Item.m_Color.r = 255; // not in use right now - Item.m_Color.g = 255; - Item.m_Color.b = 255; - Item.m_Color.a = 255; - Item.m_ColorEnv = -1; + Item.m_Color.r = pLayer->m_Color.r; + Item.m_Color.g = pLayer->m_Color.g; + Item.m_Color.b = pLayer->m_Color.b; + Item.m_Color.a = pLayer->m_Color.a; + Item.m_ColorEnv = -1; // not in use right now Item.m_ColorEnvOffset = 0; Item.m_Width = pLayer->m_Width; @@ -508,6 +508,10 @@ int CEditorMap::Load(class IStorage *pStorage, const char *pFileName, int Storag { pTiles = new CLayerTiles(pTilemapItem->m_Width, pTilemapItem->m_Height); pTiles->m_pEditor = m_pEditor; + pTiles->m_Color.r = pTilemapItem->m_Color.r; + pTiles->m_Color.g = pTilemapItem->m_Color.g; + pTiles->m_Color.b = pTilemapItem->m_Color.b; + pTiles->m_Color.a = pTilemapItem->m_Color.a; } pLayer = pTiles; diff --git a/src/game/editor/ed_layer_tiles.cpp b/src/game/editor/ed_layer_tiles.cpp index 43ed7488..71489d7c 100644 --- a/src/game/editor/ed_layer_tiles.cpp +++ b/src/game/editor/ed_layer_tiles.cpp @@ -20,6 +20,10 @@ CLayerTiles::CLayerTiles(int w, int h) m_Image = -1; m_TexId = -1; m_Game = 0; + m_Color.r = 255; + m_Color.g = 255; + m_Color.b = 255; + m_Color.a = 255; m_pTiles = new CTile[m_Width*m_Height]; mem_zero(m_pTiles, m_Width*m_Height*sizeof(CTile)); @@ -36,7 +40,7 @@ void CLayerTiles::PrepareForSave() for(int x = 0; x < m_Width; x++) m_pTiles[y*m_Width+x].m_Flags &= TILEFLAG_VFLIP|TILEFLAG_HFLIP|TILEFLAG_ROTATE; - if(m_Image != -1) + if(m_Image != -1 && m_Color.a == 255) { for(int y = 0; y < m_Height; y++) for(int x = 0; x < m_Width; x++) @@ -56,7 +60,8 @@ void CLayerTiles::Render() if(m_Image >= 0 && m_Image < m_pEditor->m_Map.m_lImages.size()) m_TexId = m_pEditor->m_Map.m_lImages[m_Image]->m_TexId; Graphics()->TextureSet(m_TexId); - m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, vec4(1,1,1,1), LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT); + vec4 Color = vec4(m_Color.r/255.0f, m_Color.g/255.0f, m_Color.b/255.0f, m_Color.a/255.0f); + m_pEditor->RenderTools()->RenderTilemap(m_pTiles, m_Width, m_Height, 32.0f, Color, LAYERRENDERFLAG_OPAQUE|LAYERRENDERFLAG_TRANSPARENT); } int CLayerTiles::ConvertX(float x) const { return (int)(x/32.0f); } @@ -373,19 +378,30 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox) PROP_HEIGHT, PROP_SHIFT, PROP_IMAGE, + PROP_COLOR, NUM_PROPS, }; + int Color = 0; + Color |= m_Color.r<<24; + Color |= m_Color.g<<16; + Color |= m_Color.b<<8; + Color |= m_Color.a; + CProperty aProps[] = { {Localize("Width"), m_Width, PROPTYPE_INT_SCROLL, 1, 1000000000}, {Localize("Height"), m_Height, PROPTYPE_INT_SCROLL, 1, 1000000000}, {Localize("Shift"), 0, PROPTYPE_SHIFT, 0, 0}, {Localize("Image"), m_Image, PROPTYPE_IMAGE, 0, 0}, + {Localize("Color"), Color, PROPTYPE_COLOR, 0, 0}, {0}, }; - if(m_pEditor->m_Map.m_pGameLayer == this) // remove the image from the selection if this is the game layer + if(m_pEditor->m_Map.m_pGameLayer == this) // remove the image and color properties if this is the game layer + { aProps[3].m_pName = 0; + aProps[4].m_pName = 0; + } static int s_aIds[NUM_PROPS] = {0}; int NewVal = 0; @@ -407,6 +423,13 @@ int CLayerTiles::RenderProperties(CUIRect *pToolBox) else m_Image = NewVal%m_pEditor->m_Map.m_lImages.size(); } + else if(Prop == PROP_COLOR) + { + m_Color.r = (NewVal>>24)&0xff; + m_Color.g = (NewVal>>16)&0xff; + m_Color.b = (NewVal>>8)&0xff; + m_Color.a = NewVal&0xff; + } return 0; } |