From: Terri00 Date: Sat, 2 Mar 2019 09:12:36 +0000 (+0000) Subject: Openfiledialogue for nav/bsp X-Git-Url: https://skaterift.com/git/?a=commitdiff_plain;h=18ba37946ce5291e3ed7397fb8328493963f55c1;p=tar-legacy.git Openfiledialogue for nav/bsp --- diff --git a/.gitignore b/.gitignore index 40147db..119185e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. +# C# experimantal libraries don't need to be uploaded +MCDV_Lib/ +MCDV_Lib_Sharp/ +MCDV_Processor/ +MCDV_Web/ + # User-specific files *.suo *.user diff --git a/MCDV/Console.hpp b/MCDV/Console.hpp index 12becfe..4cfee29 100644 --- a/MCDV/Console.hpp +++ b/MCDV/Console.hpp @@ -10,13 +10,15 @@ enum MSG_STATUS { INFO = 0, SUCCESS, - ERR + ERR, + THANKS }; std::map MSG_STATUS_COLOR { { MSG_STATUS::INFO, glm::vec3(0.75f, 0.75f, 0.75f) }, { MSG_STATUS::SUCCESS, glm::vec3(0.2f, 1.0f, 0.2f) }, - { MSG_STATUS::ERR, glm::vec3(1.0f, 0.2f, 0.2f) } + { MSG_STATUS::ERR, glm::vec3(1.0f, 0.2f, 0.2f) }, + { MSG_STATUS::THANKS, glm::vec3(0.8f, 0.3f, 0.75f) } }; class Console{ @@ -93,8 +95,10 @@ public: else if (this->cCmdBook.count(parts[0]) > 0) { this->CallCmd(parts[0]); - if(parts[0] != "HELP") - this->FeedBack(std::string("Called: *") + parts[0] + std::string( " @ 0x") + to_string((unsigned int)this->cCmdBook[parts[0]], std::hex)); + if ((parts[0] == "HELP") || (parts[0] == "THANKS")) + return; + + this->FeedBack(std::string("Called: *") + parts[0] + std::string( " @ 0x") + to_string((unsigned int)this->cCmdBook[parts[0]], std::hex)); } else { diff --git a/MCDV/main.cpp b/MCDV/main.cpp index eb411b2..7204897 100644 --- a/MCDV/main.cpp +++ b/MCDV/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -27,6 +28,11 @@ #include #include +#ifdef WIN32 +#include +#include +#endif + void framebuffer_size_callback(GLFWwindow* window, int width, int height); void processInput(GLFWwindow* window, util_keyHandler keys); void mouse_callback(GLFWwindow* window, double xpos, double ypos); @@ -71,6 +77,9 @@ std::string _filesrc_nav; Radar* _radar; +Mesh* mesh_map_bsp = NULL; +Mesh* mesh_map_nav = NULL; + int M_ORTHO_SIZE = 20; // Runtime UI stuffz @@ -86,6 +95,81 @@ void _ccmd_perspective() { SV_PERSPECTIVE = 0; } void _ccmd_orthographic() { SV_PERSPECTIVE = 1; } void _ccmd_render_image() { T_ARM_FOR_FB_RENDER = true; } void _ccmd_reset_ang() { camera.pitch = -90; camera.yaw = 0; camera.mouseUpdate(0, 0, true); } + +// Some windows stuff +#ifdef WIN32 +void _ccmd_open_nav_win() { + OPENFILENAME ofn; // common dialog box structure + char szFile[260]; // buffer for file name + //HWND hwnd; // owner window + HANDLE hf; // file handle + // Initialize OPENFILENAME + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + //ofn.hwndOwner = hwnd; + ofn.lpstrFile = szFile; + // Set lpstrFile[0] to '\0' so that GetOpenFileName does not + // use the contents of szFile to initialize itself. + ofn.lpstrFile[0] = '\0'; + ofn.nMaxFile = sizeof(szFile); + ofn.lpstrFilter = "Nav Mesh\0*.NAV\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = NULL; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + // Display the Open dialog box. + + if (GetOpenFileName(&ofn) == TRUE) { + + Nav::Mesh bob(ofn.lpstrFile); + //mesh_map_nav->~Mesh(); //Destroy old mesh + mesh_map_nav = new Mesh(bob.generateGLMesh()); + + } + else { + console.FeedBack("Couldn't read file. (getopenfilename)"); + mesh_map_nav = NULL; + } +} + +void _ccmd_open_bsp_win() { + OPENFILENAME ofn; // common dialog box structure + char szFile[260]; // buffer for file name + //HWND hwnd; // owner window + HANDLE hf; // file handle + // Initialize OPENFILENAME + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(ofn); + //ofn.hwndOwner = hwnd; + ofn.lpstrFile = szFile; + // Set lpstrFile[0] to '\0' so that GetOpenFileName does not + // use the contents of szFile to initialize itself. + ofn.lpstrFile[0] = '\0'; + ofn.nMaxFile = sizeof(szFile); + ofn.lpstrFilter = "BSP file\0*.BSP\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFileTitle = NULL; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = NULL; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + // Display the Open dialog box. + + if (GetOpenFileName(&ofn) == TRUE) { + + vbsp_level bsp_map(ofn.lpstrFile, true); + mesh_map_bsp = new Mesh(bsp_map.generate_bigmesh()); + + } + else { + console.FeedBack("Couldn't read file. (getopenfilename)"); + mesh_map_bsp = NULL; + } +} +#endif + void _ccmd_help() { console.FeedBack(R"TERRI00( @@ -122,9 +206,22 @@ Commands: )TERRI00", MSG_STATUS::SUCCESS); } +void _ccmd_thanks() { + console.FeedBack(R"TERRI00( + +Thank you: + JamDoggie + CrTech + JimWood)TERRI00", MSG_STATUS::THANKS); +} + int main(int argc, char* argv[]) { - _filesrc_bsp = "D:\\Users\\Harry\\Source\\Repos\\MCDV\\Debug\\killhouse.bsp"; - _filesrc_nav = "D:\\Users\\Harry\\Source\\Repos\\MCDV\\Debug\\killhouse.nav"; + _filesrc_bsp = "none"; + _filesrc_nav = "none"; + + _chdir(argv[0]); //Reset working directory + + std::cout << argv[0] << std::endl; for (int i = 1; i < argc; ++i) { char* _arg = argv[i]; @@ -189,17 +286,14 @@ int main(int argc, char* argv[]) { //Mesh handling ----------------------------------------------------------------------------- - Mesh* t200 = NULL; - Mesh* t201 = NULL; - - if (_filesrc_bsp != ""){ + if (_filesrc_bsp != "none"){ vbsp_level bsp_map(_filesrc_bsp, true); - t200 = new Mesh(bsp_map.generate_bigmesh()); + mesh_map_bsp = new Mesh(bsp_map.generate_bigmesh()); } - if (_filesrc_nav != "") { + if (_filesrc_nav != "none") { Nav::Mesh bob(_filesrc_nav); - t201 = new Mesh(bob.generateGLMesh()); + mesh_map_nav = new Mesh(bob.generateGLMesh()); } //Radar rtest("de_overpass.txt"); @@ -216,24 +310,32 @@ int main(int argc, char* argv[]) { TextFont::init(); //Setup textfonts before we use it + /* ui_text_info = new TextFont("Hello World!"); ui_text_info->size = glm::vec2(1.0f / window_width, 1.0f / window_height) * 2.0f; ui_text_info->alpha = 1.0f; ui_text_info->color = glm::vec3(0.75f, 0.75f, 0.75f); - ui_text_info->screenPosition = glm::vec2(0, (1.0f / window_height) * 15.0f); - + ui_text_info->screenPosition = glm::vec2(0, (1.0f / window_height) * 15.0f); */ + + ui_text_loaded = new TextFont("Currently Loaded:\n " + std::string(_filesrc_bsp) + "\n " + std::string(_filesrc_nav)); ui_text_loaded->size = glm::vec2(1.0f / window_width, 1.0f / window_height) * 2.0f; ui_text_loaded->alpha = 1.0f; - ui_text_loaded->color = glm::vec3(0.75f, 0.75f, 0.75f); + ui_text_loaded->color = glm::vec3(0.88f, 0.75f, 0.1f); ui_text_loaded->screenPosition = glm::vec2(0, 1.0f - ((1.0f / window_height) * 45.0f)); - update_globals_ui_text(ui_text_info); //Update globals + //update_globals_ui_text(ui_text_info); //Update globals //Generate console console = Console(&keys, &window_width, &window_height); console.RegisterCVar("RENDERMODE", &SV_RENDERMODE); + //Experimental +#ifdef WIN32 + console.RegisterCmd("OPENNAV", &_ccmd_open_nav_win); + console.RegisterCmd("OPENBSP", &_ccmd_open_bsp_win); +#endif + //Help console.RegisterCmd("HELP", &_ccmd_help); @@ -267,6 +369,9 @@ int main(int argc, char* argv[]) { console.RegisterCVar("FARZ", &M_CLIP_FAR); console.RegisterCVar("NEARZ", &M_CLIP_NEAR); + //Thanks + console.RegisterCmd("THANKS", &_ccmd_thanks); + //FrameBuffer t_frame_buffer = FrameBuffer(); //The main loop @@ -289,7 +394,7 @@ int main(int argc, char* argv[]) { } //Rendering commands - glClearColor(0.05f, 0.05f, 0.05f, 1.0f); + glClearColor(0.05f, 0.05f, 0.2f, 1.0f); if(T_ARM_FOR_FB_RENDER) glClearColor(0.0f, 1.0f, 0.00f, 1.0f); @@ -320,14 +425,14 @@ int main(int argc, char* argv[]) { if (SV_RENDERMODE == 0) { glEnable(GL_CULL_FACE); - if (t200 != NULL) - t200->Draw(); + if (mesh_map_bsp != NULL) + mesh_map_bsp->Draw(); } if (SV_RENDERMODE == 1) { glDisable(GL_CULL_FACE); - if (t201 != NULL) - t201->Draw(); + if (mesh_map_nav != NULL) + mesh_map_nav->Draw(); } diff --git a/MCDV/render.png b/MCDV/render.png index 21498a5..3d37b5d 100644 Binary files a/MCDV/render.png and b/MCDV/render.png differ