From 7fa21400d6739de935b2a13ceeefa32dbbb95986 Mon Sep 17 00:00:00 2001 From: xalduin Date: Tue, 8 Jun 2010 09:25:27 +0800 Subject: Mouse wheel no longer moves layer/image scrollbar --- src/game/editor/ed_editor.cpp | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 63963dc2..cd596dc3 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1655,19 +1655,6 @@ void CEditor::RenderLayers(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) LayersBox.VSplitRight(3.0f, &LayersBox, 0); // extra spacing Scroll.HMargin(5.0f, &Scroll); s_ScrollValue = UiDoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); - - if(ScrollNum > 0) - { - if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP)) - s_ScrollValue -= 3.0f/ScrollNum; - if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) - s_ScrollValue += 3.0f/ScrollNum; - - if(s_ScrollValue < 0) s_ScrollValue = 0; - if(s_ScrollValue > 1) s_ScrollValue = 1; - } - else - ScrollNum = 0; } int LayerStartAt = (int)(ScrollNum*s_ScrollValue); @@ -1953,19 +1940,6 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect ToolBar, CUIRect View) ToolBox.VSplitRight(3.0f, &ToolBox, 0); // extra spacing Scroll.HMargin(5.0f, &Scroll); s_ScrollValue = UiDoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); - - if(ScrollNum > 0) - { - if(Input()->KeyPresses(KEY_MOUSE_WHEEL_UP)) - s_ScrollValue -= 3.0f/ScrollNum; - if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) - s_ScrollValue += 3.0f/ScrollNum; - - if(s_ScrollValue < 0) s_ScrollValue = 0; - if(s_ScrollValue > 1) s_ScrollValue = 1; - } - else - ScrollNum = 0; } int ImageStartAt = (int)(ScrollNum*s_ScrollValue); -- cgit 1.4.1 From 22f11d6839599bc3fecd6b8e2b5394b58d6a7eda Mon Sep 17 00:00:00 2001 From: xalduin Date: Thu, 10 Jun 2010 07:09:51 +0800 Subject: Restore map focus on load map/new map --- src/game/editor/ed_editor.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index cd596dc3..3a47b00a 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -2839,6 +2839,19 @@ void CEditor::Reset(bool CreateDefault) m_SelectedPoints = 0; m_SelectedEnvelope = 0; m_SelectedImage = 0; + + m_WorldOffsetX = 0; + m_WorldOffsetY = 0; + m_EditorOffsetX = 0.0f; + m_EditorOffsetY = 0.0f; + + m_WorldZoom = 1.0f; + m_ZoomLevel = 200; + + m_MouseDeltaX = 0; + m_MouseDeltaY = 0; + m_MouseDeltaWx = 0; + m_MouseDeltaWy = 0; } void CEditorMap::MakeGameLayer(CLayer *pLayer) -- cgit 1.4.1 From d7c106ca900a3b9b808878bae1b4fe2021b703e0 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 11 Jun 2010 13:44:28 +0200 Subject: fixed border function in the editor. Closes #117 --- src/game/editor/ed_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 3a47b00a..ac27a5c6 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -2925,7 +2925,7 @@ void CEditor::DoMapBorder() pT->m_pTiles[i].m_Index = 1; } - for(int i = ((pT->m_Width-2)*pT->m_Height); i < pT->m_Width*pT->m_Height; ++i) + for(int i = (pT->m_Width*(pT->m_Height-2)); i < pT->m_Width*pT->m_Height; ++i) pT->m_pTiles[i].m_Index = 1; } -- cgit 1.4.1 From 3475d2ae1b66b1f254ac56a25170448aa19447b1 Mon Sep 17 00:00:00 2001 From: oy Date: Sun, 20 Jun 2010 15:27:44 +0200 Subject: fixed freeze in the map editor GUI. Closes #138 --- src/game/editor/ed_editor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index ac27a5c6..4e879c64 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1393,6 +1393,15 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) } } } + else if(UI()->ActiveItem() == s_pEditorId) + { + // release mouse + if(!UI()->MouseButton(0)) + { + s_Operation = OP_NONE; + UI()->SetActiveItem(0); + } + } if(GetSelectedGroup() && GetSelectedGroup()->m_UseClipping) { -- cgit 1.4.1 From d01776bf3f4166797c1ce9145e47e3d21b7274c2 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 22 Jun 2010 01:15:12 +0200 Subject: auto-add background when creating new map. Closes #50 --- src/game/editor/ed_editor.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 4e879c64..21ffe31f 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -2891,6 +2891,28 @@ void CEditorMap::Clean() void CEditorMap::CreateDefault(int EntitiesTexture) { + // add background + CLayerGroup *pGroup = NewGroup(); + pGroup->m_ParallaxX = 0; + pGroup->m_ParallaxY = 0; + CLayerQuads *pLayer = new CLayerQuads; + pLayer->m_pEditor = m_pEditor; + CQuad *pQuad = pLayer->NewQuad(); + const int Width = 800000; + const int Height = 600000; + pQuad->m_aPoints[0].x = pQuad->m_aPoints[2].x = -Width; + pQuad->m_aPoints[1].x = pQuad->m_aPoints[3].x = Width; + pQuad->m_aPoints[0].y = pQuad->m_aPoints[1].y = -Height; + pQuad->m_aPoints[2].y = pQuad->m_aPoints[3].y = Height; + pQuad->m_aColors[0].r = pQuad->m_aColors[1].r = 94; + pQuad->m_aColors[0].g = pQuad->m_aColors[1].g = 132; + pQuad->m_aColors[0].b = pQuad->m_aColors[1].b = 174; + pQuad->m_aColors[2].r = pQuad->m_aColors[3].r = 204; + pQuad->m_aColors[2].g = pQuad->m_aColors[3].g = 232; + pQuad->m_aColors[2].b = pQuad->m_aColors[3].b = 255; + pGroup->AddLayer(pLayer); + + // add game layer MakeGameGroup(NewGroup()); MakeGameLayer(new CLayerGame(50, 50)); m_pGameGroup->AddLayer(m_pGameLayer); @@ -3028,4 +3050,4 @@ void CEditor::UpdateAndRender() Input()->ClearEvents(); } -IEditor *CreateEditor() { return new CEditor; } +IEditor *CreateEditor() { return new CEditor; } \ No newline at end of file -- cgit 1.4.1 From 62ffaa91422df95bf1e027d9b8da8cf1053256f8 Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 22 Jun 2010 02:07:52 +0200 Subject: added a lost newline --- src/game/editor/ed_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 21ffe31f..52477095 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -3050,4 +3050,4 @@ void CEditor::UpdateAndRender() Input()->ClearEvents(); } -IEditor *CreateEditor() { return new CEditor; } \ No newline at end of file +IEditor *CreateEditor() { return new CEditor; } -- cgit 1.4.1 From 6b713157a71a617b39734160d492e6b5ec56adab Mon Sep 17 00:00:00 2001 From: oy Date: Tue, 22 Jun 2010 14:15:52 +0200 Subject: added button to restore the map focus. Closes #116 --- src/game/editor/ed_editor.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 52477095..dbb5ffe8 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -773,6 +773,17 @@ void CEditor::DoToolbar(CUIRect ToolBar) DoMapBorder(); } } + + TB_Bottom.VSplitLeft(5.0f, 0, &TB_Bottom); + + // refocus button + TB_Bottom.VSplitLeft(50.0f, &Button, &TB_Bottom); + static int s_RefocusButton = 0; + if(DoButton_Editor(&s_RefocusButton, Localize("Refocus"), m_WorldOffsetX&&m_WorldOffsetY?0:-1, &Button, 0, Localize("[HOME] Restore map focus")) || Input()->KeyDown(KEY_HOME)) + { + m_WorldOffsetX = 0; + m_WorldOffsetY = 0; + } } static void Rotate(CPoint *pCenter, CPoint *pPoint, float Rotation) -- cgit 1.4.1 From 82f5a56d89005b94493f63ca1d00031d194966b6 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 25 Jun 2010 18:56:58 +0200 Subject: fixed crash in the map editor --- src/game/editor/ed_editor.cpp | 38 ++++++++++++++++++++------------------ src/game/editor/ed_popups.cpp | 1 + 2 files changed, 21 insertions(+), 18 deletions(-) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index dbb5ffe8..8e777218 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -1328,24 +1328,26 @@ void CEditor::DoMapEditor(CUIRect View, CUIRect ToolBar) } CLayerGroup *g = GetSelectedGroup(); - m_Brush.m_OffsetX += g->m_OffsetX; - m_Brush.m_OffsetY += g->m_OffsetY; - m_Brush.m_ParallaxX = g->m_ParallaxX; - m_Brush.m_ParallaxY = g->m_ParallaxY; - m_Brush.Render(); - float w, h; - m_Brush.GetSize(&w, &h); - - IGraphics::CLineItem Array[4] = { - IGraphics::CLineItem(0, 0, w, 0), - IGraphics::CLineItem(w, 0, w, h), - IGraphics::CLineItem(w, h, 0, h), - IGraphics::CLineItem(0, h, 0, 0)}; - Graphics()->TextureSet(-1); - Graphics()->LinesBegin(); - Graphics()->LinesDraw(Array, 4); - Graphics()->LinesEnd(); - + if(g) + { + m_Brush.m_OffsetX += g->m_OffsetX; + m_Brush.m_OffsetY += g->m_OffsetY; + m_Brush.m_ParallaxX = g->m_ParallaxX; + m_Brush.m_ParallaxY = g->m_ParallaxY; + m_Brush.Render(); + float w, h; + m_Brush.GetSize(&w, &h); + + IGraphics::CLineItem Array[4] = { + IGraphics::CLineItem(0, 0, w, 0), + IGraphics::CLineItem(w, 0, w, h), + IGraphics::CLineItem(w, h, 0, h), + IGraphics::CLineItem(0, h, 0, 0)}; + Graphics()->TextureSet(-1); + Graphics()->LinesBegin(); + Graphics()->LinesDraw(Array, 4); + Graphics()->LinesEnd(); + } } } } diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp index 5e833ba6..08ec51cb 100644 --- a/src/game/editor/ed_popups.cpp +++ b/src/game/editor/ed_popups.cpp @@ -84,6 +84,7 @@ int CEditor::PopupGroup(CEditor *pEditor, CUIRect View) pEditor->DoButton_Editor(&s_DeleteButton, Localize("Delete group"), 0, &Button, 0, Localize("Delete group"))) { pEditor->m_Map.DeleteGroup(pEditor->m_SelectedGroup); + pEditor->m_SelectedGroup = max(0, pEditor->m_SelectedGroup-1); return 1; } -- cgit 1.4.1 From ff3eda23ae7608bfc7e9e79bbcb1c9db571ebaa7 Mon Sep 17 00:00:00 2001 From: oy Date: Fri, 25 Jun 2010 19:41:55 +0200 Subject: automatically add the map extension when saving a map with the editor --- src/game/editor/ed_editor.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_editor.cpp b/src/game/editor/ed_editor.cpp index 8e777218..da97ed61 100644 --- a/src/game/editor/ed_editor.cpp +++ b/src/game/editor/ed_editor.cpp @@ -573,7 +573,21 @@ static void CallbackAppendMap(const char *pFileName, void *pUser) else pEditor->SortImages(); } -static void CallbackSaveMap(const char *pFileName, void *pUser){ if(((CEditor*)pUser)->Save(pFileName)) str_copy(((CEditor*)pUser)->m_aFileName, pFileName, 512); } +static void CallbackSaveMap(const char *pFileName, void *pUser) +{ + char aBuf[1024]; + const int Length = str_length(pFileName); + // add map extension + if(Length <= 4 || pFileName[Length-4] != '.' || str_comp_nocase(pFileName+Length-3, "map")) + { + str_format(aBuf, sizeof(aBuf), "%s.map", pFileName); + pFileName = aBuf; + } + + CEditor *pEditor = static_cast(pUser); + if(pEditor->Save(pFileName)) + str_copy(pEditor->m_aFileName, pFileName, sizeof(pEditor->m_aFileName)); +} void CEditor::DoToolbar(CUIRect ToolBar) { @@ -593,7 +607,7 @@ void CEditor::DoToolbar(CUIRect ToolBar) if(Input()->KeyDown('s') && (Input()->KeyPressed(KEY_LCTRL) || Input()->KeyPressed(KEY_RCTRL))) { if(m_aFileName[0]) - Save(m_aFileName); + CallbackSaveMap(m_aFileName, this); else InvokeFileDialog(IStorage::TYPE_SAVE, Localize("Save map"), Localize("Save"), "maps/", "", CallbackSaveMap, this); } @@ -2666,7 +2680,7 @@ int CEditor::PopupMenuFile(CEditor *pEditor, CUIRect View) if(pEditor->DoButton_MenuItem(&s_SaveButton, Localize("Save"), 0, &Slot, 0, Localize("Saves the current map"))) { if(pEditor->m_aFileName[0]) - pEditor->Save(pEditor->m_aFileName); + CallbackSaveMap(pEditor->m_aFileName, pEditor); else pEditor->InvokeFileDialog(IStorage::TYPE_SAVE, Localize("Save Map"), Localize("Save"), "maps/", "", CallbackSaveMap, pEditor); return 1; -- cgit 1.4.1 From bd02c2043e9f76ec47ee9ac35caf23ae294b1dfa Mon Sep 17 00:00:00 2001 From: oy Date: Mon, 28 Jun 2010 15:12:43 +0200 Subject: fixed editor popups shown outside the screen --- src/game/editor/ed_popups.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/game/editor') diff --git a/src/game/editor/ed_popups.cpp b/src/game/editor/ed_popups.cpp index 08ec51cb..001a7249 100644 --- a/src/game/editor/ed_popups.cpp +++ b/src/game/editor/ed_popups.cpp @@ -20,6 +20,10 @@ static int g_UiNumPopups = 0; void CEditor::UiInvokePopupMenu(void *Id, int Flags, float x, float y, float w, float h, int (*pfnFunc)(CEditor *pEditor, CUIRect Rect), void *pExtra) { dbg_msg("", "invoked"); + if(x + w > UI()->Screen()->w) + x -= w; + if(y + h > UI()->Screen()->h) + y -= h; s_UiPopups[g_UiNumPopups].m_pId = Id; s_UiPopups[g_UiNumPopups].m_IsMenu = Flags; s_UiPopups[g_UiNumPopups].m_Rect.x = x; -- cgit 1.4.1