double-hit-balls/game/galaxy_menu.h

93 lines
2.7 KiB
C
Raw Normal View History

2018-05-22 12:00:30 +00:00
#ifndef GALAXY_MENU_H
#define GALAXY_MENU_H
#include <vector>
#include <string>
#include "galaxy.h"
2018-06-01 11:45:16 +00:00
#include "level_interior.h"
2018-05-22 12:00:30 +00:00
2018-05-23 11:46:02 +00:00
#include "include/Engine.h"
#include <boost/property_tree/json_parser.hpp>
#include <math.h>
2018-05-22 12:00:30 +00:00
class GalaxyMenu {
public:
GalaxyMenu();
~GalaxyMenu();
// ======== All objects =========
std::vector<Galaxy> galaxies;
// ======== All objects =========
// ======== Main Methods ========
2018-05-23 11:46:02 +00:00
bool InitGalaxyMenu(std::string config_json, float scale = 1.f);
2018-05-22 12:00:30 +00:00
void DrawGalaxyMenu();
2018-05-28 11:31:01 +00:00
void UpdateGalaxyMenu(float s_width, float s_height, size_t dt);
2018-05-22 12:00:30 +00:00
// ======== Main Methods ========
2018-05-25 11:51:26 +00:00
void InteractWithGalaxy(size_t dt); // Prototype for mouse/tap events
2018-05-22 12:00:30 +00:00
2018-05-23 11:46:02 +00:00
// ::#Params#::
Eigen::Vector2f menuPosition = Eigen::Vector2f(0.f, 0.f); // relative to the screen center(0.f,0.f means center) (not const!!)
float menuScale = 1.f; // (not const!!)
float xDimension;
float yDimension;
2018-05-25 11:51:26 +00:00
float anchorSize = 1.f;
2018-05-24 11:44:58 +00:00
std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>> galaxies_params; // ::position/dimensions::
std::vector<std::vector<std::pair<Eigen::Vector2f, Eigen::Vector2f>>> stars_params;
2018-05-22 12:00:30 +00:00
2018-05-25 11:51:26 +00:00
/*..Outer Interact..*/
void tapDown(Eigen::Vector2f pos);
void tapUp(Eigen::Vector2f pos);
void tapMove(Eigen::Vector2f shift);
2018-05-22 12:00:30 +00:00
private:
2018-06-01 11:45:16 +00:00
2018-05-22 12:00:30 +00:00
void readSaveData(); // inner init method
2018-05-30 11:21:50 +00:00
/*..calc methodes..*/
2018-05-23 11:46:02 +00:00
Eigen::Vector2f textureSizeNormalize(Eigen::Vector2f texVec, int t_type = 0/*0-galaxy, 1-stars*/);
float val_clamp(float v, float min, float max);
2018-05-25 11:51:26 +00:00
Eigen::Vector2f findCorner(int x_c, int y_c);
float graterV(float first_v, float second_v);
float lowerV(float first_v, float second_v);
2018-05-28 11:31:01 +00:00
int negativeV(float val);
2018-05-25 11:51:26 +00:00
2018-05-30 11:21:50 +00:00
/*..states..*/
int menuState = 0; // 0 - all galaxies are visible, 1 - zoomed to current galaxy(reserved) , 2 - level select menu
int starIndex = -1;
int galaxyIndex = 0; // zoomed galaxy
int planetHoverIndex = -1;
2018-05-25 11:51:26 +00:00
/*..Interact params..*/
bool timer_active = false;
2018-05-28 11:31:01 +00:00
float interact_timer = 0.f; // reset
Eigen::Vector2f lastTapPos = Eigen::Vector2f(-9999.9f, -9999.9f); // reset
Eigen::Vector2f currentTapShift; // reset
Eigen::Vector2f totalTapShift; // reset
/*..coefficients..*/
2018-05-31 11:47:18 +00:00
Eigen::Vector2f menu_offset = Eigen::Vector2f(0, 0);
2018-05-25 11:51:26 +00:00
/*..Interact methods..*/
2018-05-28 11:31:01 +00:00
void takeInFocus(int g_index, int s_index = -1);
2018-05-25 11:51:26 +00:00
int findGalaxyByPos(Eigen::Vector2f pos);
2018-05-28 11:31:01 +00:00
int findPlanetByPos(Eigen::Vector2f pos);
2018-05-30 11:21:50 +00:00
int findLevelButtonByPos(Eigen::Vector2f pos);
bool checkMenuBound(Eigen::Vector2f pos);
2018-05-28 11:31:01 +00:00
2018-05-30 11:21:50 +00:00
/*..draw methodes..*/
void drawSelectionMenu(int index);
void drawBorder(Eigen::Vector2f lb_, Eigen::Vector2f rt_, float scale, std::string mode);
2018-06-01 11:45:16 +00:00
void drawLevelInterior(int star = -1, int button = -1);
2018-05-22 12:00:30 +00:00
};
#endif