2013-01-19 22:25:53 +00:00
|
|
|
#include "main_code.h"
|
|
|
|
|
|
|
|
#ifdef TARGET_ANDROID
|
|
|
|
#include "android_api.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include "include/Engine.h"
|
|
|
|
|
|
|
|
#include "main_code.h"
|
|
|
|
|
|
|
|
#ifndef TARGET_IOS
|
2018-02-05 14:53:52 +00:00
|
|
|
std::shared_ptr<TMyApplication> App = std::make_shared<TMyApplication>();
|
2013-01-19 22:25:53 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
bool animPaused = false;
|
|
|
|
|
2018-02-02 09:09:09 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
struct TOnClickTest
|
|
|
|
{
|
|
|
|
void operator()()
|
|
|
|
{
|
|
|
|
|
|
|
|
//ResourceManager->ScriptManager.RunScript("5+5;");
|
|
|
|
|
|
|
|
if (animPaused)
|
|
|
|
{
|
|
|
|
//animPaused = false;
|
|
|
|
//ResourceManager->HalibutAnimationManager.StartAnimation("test_anim");
|
|
|
|
//ResourceManager->HalibutAnimationManager.ShowAnimation("test_anim");
|
|
|
|
//ResourceManager->SoundManager.PlayMusic("finalogg.ogg");
|
|
|
|
|
|
|
|
//App->Match3Controller.Match3Field->StartAnimateChip(4,1);
|
|
|
|
|
|
|
|
//App->Match3Controller.Match3Field->HighlightMatch3();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//animPaused = true;
|
|
|
|
//ResourceManager->HalibutAnimationManager.StopAnimation("test_anim");
|
|
|
|
//ResourceManager->HalibutAnimationManager.HideAnimation("test_anim");
|
|
|
|
//ResourceManager->SoundManager.StopMusic("finalogg.ogg");
|
|
|
|
//App->Match3Controller.Match3Field->StopAnimateChip(4,1);
|
|
|
|
//App->Match3Controller.Match3Field->HighlightMatch3();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//What to do on init
|
|
|
|
void TMyApplication::InnerInit()
|
|
|
|
{
|
|
|
|
#ifdef TARGET_ANDROID
|
2018-02-01 14:39:31 +00:00
|
|
|
SE::ST::PathToResources = "";
|
2013-01-19 22:25:53 +00:00
|
|
|
#endif
|
|
|
|
#ifdef TARGET_WIN32
|
|
|
|
#ifdef DEBUG
|
2018-02-01 14:39:31 +00:00
|
|
|
SE::ST::PathToResources = "../../assets/";
|
2013-01-19 22:25:53 +00:00
|
|
|
#else
|
2018-02-01 14:39:31 +00:00
|
|
|
SE::ST::PathToResources = "res/";
|
2013-01-19 22:25:53 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#ifdef TARGET_IOS
|
2018-02-01 14:39:31 +00:00
|
|
|
SE::ST::PathToResources = "assets/";
|
2013-01-19 22:25:53 +00:00
|
|
|
#endif
|
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
if (SE::Console != nullptr) {
|
|
|
|
*SE::Console << "APP INIT\n";
|
|
|
|
}
|
2013-01-19 22:25:53 +00:00
|
|
|
|
2018-02-01 14:39:31 +00:00
|
|
|
SE::ResourceManager->ShaderManager.AddShader("DefaultShader", "shader1vertex.txt", "shader1fragment.txt");
|
|
|
|
SE::ResourceManager->ShaderManager.AddShader("FrameShader", "frameshader_vertex.txt", "frameshader_fragment.txt");
|
|
|
|
SE::ResourceManager->ShaderManager.AddShader("BrickShader", "brickshader_vertex.txt", "brickshader_fragment.txt");
|
|
|
|
SE::Renderer->PushShader("DefaultShader");
|
|
|
|
|
|
|
|
const std::string CONST_LOADING_BACKGROUND_BLACK = "loading_background_black";
|
|
|
|
const std::string CONST_LOADING_TEXTURE = "loading";
|
|
|
|
const std::string CONST_LOGO_SMALL_TEXTURE = "logo_small";
|
|
|
|
|
|
|
|
SE::ResourceManager->TexList.AddTexture(CONST_LOADING_BACKGROUND_BLACK + ".png", CONST_LOADING_BACKGROUND_BLACK);
|
|
|
|
SE::ResourceManager->TexList.AddTexture(CONST_LOADING_TEXTURE + ".png", CONST_LOADING_TEXTURE);
|
|
|
|
SE::ResourceManager->TexList.AddTexture(CONST_LOGO_SMALL_TEXTURE + ".png", CONST_LOGO_SMALL_TEXTURE);
|
|
|
|
|
|
|
|
SE::ResourceManager->TexList.AddTexture("console_bkg.bmp");
|
|
|
|
|
|
|
|
SE::ResourceManager->FrameManager.AddFrameRenderBuffer("LevelBuffer", 512, 512);
|
|
|
|
|
|
|
|
Inited = true;
|
|
|
|
|
|
|
|
SE::Renderer->SetOrthoProjection();
|
|
|
|
|
|
|
|
SE::Renderer->SetFullScreenViewport();
|
|
|
|
|
|
|
|
|
|
|
|
auto px = SE::FileToPropertyTree("shaders.xml");
|
|
|
|
SE::ResourceManager->ShaderManager.Serialize(*px);
|
|
|
|
|
|
|
|
px = SE::FileToPropertyTree("textures.xml");
|
|
|
|
SE::ResourceManager->TexList.Serialize(*px);
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
//this cause exception
|
|
|
|
//px = SE::FileToPropertyTree("fonts.xml");
|
|
|
|
//SE::ResourceManager->FontManager.Serialize(*px);
|
|
|
|
//SE::ResourceManager->FontManager.PushFont("droid_sans14");
|
2018-02-02 09:09:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-02 15:00:17 +00:00
|
|
|
Match3Controller.Match3Field = std::make_shared<TMatch3Field>(Match3Controller);
|
2018-02-02 09:09:09 +00:00
|
|
|
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//What to do on deinit
|
|
|
|
void TMyApplication::InnerDeinit()
|
|
|
|
{
|
|
|
|
Inited = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//What to do on draw
|
|
|
|
void TMyApplication::InnerDraw()
|
|
|
|
{
|
2018-02-02 15:00:17 +00:00
|
|
|
auto &list = Match3Controller.Match3Field.get()->TriangleListVector;
|
|
|
|
|
|
|
|
for (auto j = list.begin(); j != list.end(); ++j)
|
2018-02-02 09:09:09 +00:00
|
|
|
{
|
2018-02-02 15:00:17 +00:00
|
|
|
SE::TRenderParamsSetter paramSetter(j->first);
|
|
|
|
SE::Renderer->DrawTriangleList(j->second);
|
|
|
|
SE::CheckGlError("TMyApplication::InnerDraw()");
|
2018-02-02 09:09:09 +00:00
|
|
|
}
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//What to do on update. timer means how many ms passed since last update
|
2018-02-01 14:39:31 +00:00
|
|
|
void TMyApplication::InnerUpdate(size_t timer)
|
2013-01-19 22:25:53 +00:00
|
|
|
{
|
2018-02-02 15:00:17 +00:00
|
|
|
Match3Controller.Match3Field.get()->Update(timer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMyApplication::InnerOnTapDown(Eigen::Vector2f p) {
|
|
|
|
if (!Match3Controller.Match3Field.get()->CheckClick(p)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Match3Controller.Match3Field.get()->OnTapDown(p);
|
2013-01-19 22:25:53 +00:00
|
|
|
}
|
2018-02-02 15:00:17 +00:00
|
|
|
|
|
|
|
void TMyApplication::InnerOnTapUp(Eigen::Vector2f p) {
|
|
|
|
if (!Match3Controller.Match3Field.get()->CheckClick(p)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Match3Controller.Match3Field.get()->OnTapUp(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMyApplication::InnerOnMove(Eigen::Vector2f pos, Eigen::Vector2f shift) {
|
2018-02-05 14:53:52 +00:00
|
|
|
// if (!Match3Controller.Match3Field.get()->CheckClick(pos)) {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// Match3Controller.Match3Field.get()->OnMove(pos);
|
2018-02-02 15:00:17 +00:00
|
|
|
}
|