mirror of
https://github.com/devZoGok/PlanetFleet.git
synced 2026-08-26 19:43:29 +00:00
clicking on the minimap moves the camera
This commit is contained in:
@@ -2,6 +2,7 @@ res = graphics.resolution
|
||||
Size = {x = 70, y = 70}
|
||||
sz = 210
|
||||
s = 40
|
||||
minimapSize = {x = 200, y = 200}
|
||||
resTextScale = {x = .5, y = .5}
|
||||
resIconBasePath = 'Icons/Resources/'
|
||||
pointerTex = 'pointer.png'
|
||||
@@ -9,6 +10,14 @@ attackTex = 'attack.png'
|
||||
garrisonTex = 'garrison.png'
|
||||
|
||||
gui = {
|
||||
{
|
||||
guiType = GuiType.BUTTON,
|
||||
buttonType = ButtonType.MINIMAP,
|
||||
name = 'minimap',
|
||||
pos = {x = res.x - minimapSize.x, y = 0, z = 0},
|
||||
size = minimapSize,
|
||||
color = {x = .5, y = .5, z = .5, w = 1}
|
||||
},
|
||||
{
|
||||
guiType = GuiType.TEXT,
|
||||
name = 'refineds',
|
||||
|
||||
@@ -37,7 +37,8 @@ ButtonType = {
|
||||
PLAYER_TRADE = 33,
|
||||
TRADING_SCREEN = 34,
|
||||
TRADE_OFFER = 35,
|
||||
RESOURCE_AMMOUNT = 36
|
||||
RESOURCE_AMMOUNT = 36,
|
||||
MINIMAP = 37
|
||||
}
|
||||
|
||||
ListboxType = {
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ set(OPTIONS_BUTTONS optionsButton.cpp tabButton.cpp okButton.cpp defaultsButton.
|
||||
set(TRADING_BUTTONS playerTradeButton.cpp tradingScreenButton.cpp offerButton.cpp resourceAmmountButton.cpp)
|
||||
set(MENU_BUTTONS mainMenuButton.cpp singlePlayerButton.cpp exitButton.cpp backButton.cpp playButton.cpp)
|
||||
set(MAP_EDITOR_BUTTONS mapEditorButton.cpp newMapButton.cpp loadMapButton.cpp exportButton.cpp)
|
||||
set(BUTTONS statsButton.cpp activeStateButton.cpp ${TRADING_BUTTONS} ${OPTIONS_BUTTONS} ${MENU_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS})
|
||||
set(BUTTONS statsButton.cpp activeStateButton.cpp minimapButton.cpp ${TRADING_BUTTONS} ${OPTIONS_BUTTONS} ${MENU_BUTTONS} ${MAP_EDITOR_BUTTONS} ${UNIT_BUTTONS})
|
||||
|
||||
set(LISTBOXES skyboxTextureListbox.cpp landTextureListbox.cpp gameObjectListbox.cpp)
|
||||
set(GUI tooltip.cpp concreteGuiManager.cpp ${BUTTONS} ${LISTBOXES})
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "tradingScreenButton.h"
|
||||
#include "offerButton.h"
|
||||
#include "resourceAmmountButton.h"
|
||||
#include "minimapButton.h"
|
||||
|
||||
namespace battleship{
|
||||
using namespace std;
|
||||
@@ -261,6 +262,9 @@ namespace battleship{
|
||||
case RESOURCE_AMMOUNT:
|
||||
button = new ResourceAmmountButton(pos, size, name, (int)guiTable["ammount"], (int)guiTable["trigger"], imagePath);
|
||||
break;
|
||||
case MINIMAP:
|
||||
button = new MinimapButton(pos, size, "");
|
||||
break;
|
||||
}
|
||||
|
||||
int typeArr[2]{(int)GuiElementType::BUTTON, (int)type};
|
||||
|
||||
@@ -51,7 +51,8 @@ namespace battleship{
|
||||
PLAYER_TRADE,
|
||||
TRADING_SCREEN,
|
||||
TRADE_OFFER,
|
||||
RESOURCE_AMMOUNT
|
||||
RESOURCE_AMMOUNT,
|
||||
MINIMAP
|
||||
};
|
||||
enum ListboxType {
|
||||
CONTROLS,
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#include "minimapButton.h"
|
||||
#include "map.h"
|
||||
|
||||
#include <node.h>
|
||||
|
||||
namespace battleship{
|
||||
using namespace vb01;
|
||||
using namespace std;
|
||||
|
||||
MinimapButton::MinimapButton(Vector3 pos, Vector2 size, string ip) : Button(pos, size, "minimap", "", -1, true, ip){
|
||||
content = new Node();
|
||||
rectNode->attachChild(content);
|
||||
}
|
||||
|
||||
MinimapButton::~MinimapButton(){
|
||||
}
|
||||
|
||||
void MinimapButton::update(){
|
||||
Button::update();
|
||||
}
|
||||
|
||||
void MinimapButton::onClick(){
|
||||
Vector2 clickPos = getCursorPos();
|
||||
float posXRatio = (clickPos.x - pos.x) / size.x;
|
||||
float posYRatio = (clickPos.y - pos.y) / size.y;
|
||||
|
||||
Camera *cam = Root::getSingleton()->getCamera();
|
||||
Vector3 mapSize = Map::getSingleton()->getMapSize();
|
||||
cam->setPosition(Vector3(mapSize.x * (-.5 + posXRatio), cam->getPosition().y, mapSize.z * (-.5 + posYRatio)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef MINIMAP_BUTTON_H
|
||||
#define MINIMAP_BUTTON_H
|
||||
|
||||
#include <button.h>
|
||||
|
||||
namespace vb01{
|
||||
class Node;
|
||||
}
|
||||
|
||||
namespace battleship{
|
||||
class MinimapButton : public vb01Gui::Button{
|
||||
public:
|
||||
MinimapButton(vb01::Vector3, vb01::Vector2, std::string);
|
||||
~MinimapButton();
|
||||
void onClick();
|
||||
void update();
|
||||
private:
|
||||
vb01::Node *content = nullptr;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user