From c7c9cae999199ba85a5f8a7a0b722c3f9953335d Mon Sep 17 00:00:00 2001 From: fgenesis Date: Thu, 25 May 2023 17:54:38 +0200 Subject: [PATCH] remove semi-broken editor tile alignment functions and related code --- Aquaria/SceneEditor.cpp | 75 ----------------------------------------- Aquaria/SceneEditor.h | 3 -- BBGE/Texture.cpp | 56 ------------------------------ BBGE/Texture.h | 3 -- 4 files changed, 137 deletions(-) diff --git a/Aquaria/SceneEditor.cpp b/Aquaria/SceneEditor.cpp index 555ade9..95a3912 100644 --- a/Aquaria/SceneEditor.cpp +++ b/Aquaria/SceneEditor.cpp @@ -513,11 +513,6 @@ void SceneEditor::init() addAction(MakeFunctionEvent(SceneEditor, mouseButtonLeftUp), MOUSE_BUTTON_LEFT, 0); addAction(MakeFunctionEvent(SceneEditor, mouseButtonRightUp), MOUSE_BUTTON_RIGHT, 0); - addAction(MakeFunctionEvent(SceneEditor, alignHorz), KEY_C, 1); - addAction(MakeFunctionEvent(SceneEditor, alignVert), KEY_V, 1); - - - addAction(MakeFunctionEvent(SceneEditor, placeElement), KEY_SPACE, 1); addAction(MakeFunctionEvent(SceneEditor, enterName), KEY_N, 0); @@ -627,76 +622,6 @@ void SceneEditor::init() doPrevElement(); } -void SceneEditor::alignHorz() -{ - if (core->getShiftState()) return; - if (editType == ET_ELEMENTS && state == ES_SELECTING && editingElement) - { - TileVector t(editingElement->position); - int startOn = dsq->game->getGrid(t); - TileVector c=t; - bool found = false; - int dir = -1; - for (int i = 1; i < 5; i++) - { - // search down - c.y = t.y + i; - if (dsq->game->getGrid(c) != startOn) - { - found = true; - dir = 1; - break; - } - c.y = t.y - i; - if (dsq->game->getGrid(c) != startOn) - { - found = true; - dir = -1; - break; - } - } - if (found) - { - editingElement->position.y = c.worldVector().y + (editingElement->texture->getPixelHeight()/2)*(-dir); - } - } -} - -void SceneEditor::alignVert() -{ - if (core->getShiftState()) return; - if (editType == ET_ELEMENTS && state == ES_SELECTING && editingElement) - { - TileVector t(editingElement->position); - int startOn = dsq->game->getGrid(t); - TileVector c=t; - bool found = false; - int dir = -1; - for (int i = 1; i < 5; i++) - { - // search down - c.x = t.x + i; - if (dsq->game->getGrid(c) != startOn) - { - found = true; - dir = 1; - break; - } - c.x = t.x - i; - if (dsq->game->getGrid(c) != startOn) - { - found = true; - dir = -1; - break; - } - } - if (found) - { - editingElement->position.x = c.worldVector().x + (editingElement->texture->getPixelWidth()/2)*(-dir); - } - } -} - void SceneEditor::createAquarian() { diff --git a/Aquaria/SceneEditor.h b/Aquaria/SceneEditor.h index fa97793..72d2ad0 100644 --- a/Aquaria/SceneEditor.h +++ b/Aquaria/SceneEditor.h @@ -114,9 +114,6 @@ public: void exitMoveState(); - void alignHorz(); - void alignVert(); - EditTypes editType; EditorStates state; diff --git a/BBGE/Texture.cpp b/BBGE/Texture.cpp index bb3ef2a..ea81405 100644 --- a/BBGE/Texture.cpp +++ b/BBGE/Texture.cpp @@ -137,62 +137,6 @@ void Texture::destroy() core->removeTexture(this); } -// FIXME: this should be recorded at load-time -- fg -int Texture::getPixelWidth() -{ - int w = 0, h = 0; - unsigned int size = 0; - unsigned char *data = getBufferAndSize(&w, &h, &size); - if (!data) - return 0; - - size_t smallestx = -1, largestx = 0; - for (unsigned int x = 0; x < unsigned(w); x++) - { - for (unsigned int y = 0; y < unsigned(h); y++) - { - unsigned int p = (y*unsigned(w)*4) + (x*4) + 3; - if (p < size && data[p] >= 254) - { - if (x < smallestx) - smallestx = x; - if (x > largestx) - largestx = x; - } - } - } - free(data); - return largestx - smallestx; -} - -// FIXME: same as above -int Texture::getPixelHeight() -{ - int w = 0, h = 0; - unsigned int size = 0; - unsigned char *data = getBufferAndSize(&w, &h, &size); - if (!data) - return 0; - - size_t smallesty = -1, largesty = 0; - for (unsigned int x = 0; x < unsigned(w); x++) - { - for (unsigned int y = 0; y < unsigned(h); y++) - { - size_t p = (y*unsigned(w)*4) + (x*4) + 3; - if (p < size && data[p] >= 254) - { - if (y < smallesty) - smallesty = y; - if (y > largesty) - largesty = y; - } - } - } - free(data); - return largesty - smallesty; -} - void Texture::reload() { debugLog("RELOADING TEXTURE: " + name + " with loadName " + loadName + "..."); diff --git a/BBGE/Texture.h b/BBGE/Texture.h index 47a94ad..734a274 100644 --- a/BBGE/Texture.h +++ b/BBGE/Texture.h @@ -43,9 +43,6 @@ public: void apply(bool repeat = false) const; void unload(); - int getPixelWidth(); - int getPixelHeight(); - void destroy(); int width, height;