Merge branch 'master' of https://bitbucket.org/omigamedev/new_engine
This commit is contained in:
@@ -202,6 +202,7 @@
|
||||
<ClCompile Include="src\node_dialog_layer_rename.cpp" />
|
||||
<ClCompile Include="src\node_dialog_open.cpp" />
|
||||
<ClCompile Include="src\node_dialog_picker.cpp" />
|
||||
<ClCompile Include="src\node_dialog_resize.cpp" />
|
||||
<ClCompile Include="src\node_icon.cpp" />
|
||||
<ClCompile Include="src\node_image.cpp" />
|
||||
<ClCompile Include="src\node_image_texture.cpp" />
|
||||
@@ -320,6 +321,7 @@
|
||||
<ClInclude Include="src\node_dialog_layer_rename.h" />
|
||||
<ClInclude Include="src\node_dialog_open.h" />
|
||||
<ClInclude Include="src\node_dialog_picker.h" />
|
||||
<ClInclude Include="src\node_dialog_resize.h" />
|
||||
<ClInclude Include="src\node_icon.h" />
|
||||
<ClInclude Include="src\node_image.h" />
|
||||
<ClInclude Include="src\node_image_texture.h" />
|
||||
|
||||
@@ -261,6 +261,9 @@
|
||||
<ClCompile Include="src\node_usermanual.cpp">
|
||||
<Filter>Source Files\ui</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\node_dialog_resize.cpp">
|
||||
<Filter>Source Files\ui</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\app.h">
|
||||
@@ -467,6 +470,9 @@
|
||||
<ClInclude Include="src\node_usermanual.h">
|
||||
<Filter>Header Files\ui</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\node_dialog_resize.h">
|
||||
<Filter>Header Files\ui</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="PanoPainter.rc">
|
||||
|
||||
@@ -400,7 +400,7 @@
|
||||
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||
<border dir="row" align="center" height="30" color=".2 .2 .2 1">
|
||||
<text text="New name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
|
||||
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
<text-input id="txt-input" align="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
</border>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
<button id="btn-ok" text="Rename Layer" width="110" height="30" margin="0 10 0 0"/>
|
||||
@@ -539,7 +539,7 @@
|
||||
<border width="400" color="0 0 0 .9" pad="10" dir="col">
|
||||
<border dir="row" align="center" height="30" color=".2 .2 .2 1">
|
||||
<text text="Project name: " font-face="arial" font-size="11" margin="0 5 0 5"/>
|
||||
<text-input id="txt-input" justify="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
<text-input id="txt-input" align="center" pad="5" grow="1" height="30" color=".3"/>
|
||||
</border>
|
||||
<text os="win,osx" id="path" text="Workind dir: path" text-wrap-width="470" font-face="arial" font-size="11" margin="10 5 10 5"/>
|
||||
<node height="40" grow="1" dir="row" align="flex-end" justify="flex-end">
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
void displayKeyboard(android_app* mApplication, bool pShow);
|
||||
void pick_file(android_app* mApplication, std::function<void(std::string)> callback);
|
||||
#elif _WIN32
|
||||
std::string win32_open_file();
|
||||
std::string win32_open_file(const char* filter);
|
||||
std::string win32_open_dir();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -64,7 +65,7 @@ void App::pick_image(std::function<void(std::string path)> callback)
|
||||
#elif __ANDROID__
|
||||
pick_file(and_app, callback);
|
||||
#elif _WIN32
|
||||
std::string path = win32_open_file();
|
||||
std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
|
||||
if (!path.empty())
|
||||
callback(path);
|
||||
#endif
|
||||
@@ -89,7 +90,21 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
|
||||
#elif __ANDROID__
|
||||
pick_file(and_app, callback);
|
||||
#elif _WIN32
|
||||
std::string path = win32_open_file();
|
||||
std::string filter = "Image Files (";
|
||||
bool first_type = true;
|
||||
for (auto& t : types)
|
||||
{
|
||||
filter += std::string(first_type ? "" : " ,") + "*." + t;
|
||||
first_type = false;
|
||||
}
|
||||
filter += ")\0";
|
||||
first_type = true;
|
||||
for (auto& t : types)
|
||||
{
|
||||
filter += std::string(first_type ? "" : ";") + "*." + t;
|
||||
first_type = false;
|
||||
}
|
||||
std::string path = win32_open_file(filter.c_str());
|
||||
if (!path.empty())
|
||||
callback(path);
|
||||
#endif
|
||||
@@ -110,9 +125,9 @@ void App::pick_dir(std::function<void(std::string path)> callback)
|
||||
// NOT IMPLEMENTED
|
||||
#elif _WIN32
|
||||
// TODO: to be implemented
|
||||
// std::string path = win32_open_file();
|
||||
// if (!path.empty())
|
||||
// callback(path);
|
||||
std::string path = win32_open_dir();
|
||||
if (!path.empty())
|
||||
callback(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
48
src/main.cpp
48
src/main.cpp
@@ -107,14 +107,14 @@ void async_unlock()
|
||||
}
|
||||
}
|
||||
|
||||
std::string win32_open_file()
|
||||
std::string win32_open_file(const char* filter)
|
||||
{
|
||||
OPENFILENAMEA ofn;
|
||||
char fileName[MAX_PATH] = "";
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(OPENFILENAME);
|
||||
ofn.hwndOwner = hWnd;
|
||||
ofn.lpstrFilter = "Image Files (*.jpg, *.png)\0*.jpg;*.png";
|
||||
ofn.lpstrFilter = filter;
|
||||
ofn.lpstrFile = fileName;
|
||||
ofn.nMaxFile = MAX_PATH;
|
||||
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
|
||||
@@ -127,6 +127,22 @@ std::string win32_open_file()
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string win32_open_dir()
|
||||
{
|
||||
BROWSEINFOA bi;
|
||||
char Buffer[MAX_PATH];
|
||||
ZeroMemory(Buffer, MAX_PATH);
|
||||
ZeroMemory(&bi, sizeof(bi));
|
||||
bi.hwndOwner = hWnd;
|
||||
bi.pszDisplayName = Buffer;
|
||||
bi.lpszTitle = "Title";
|
||||
bi.ulFlags = BIF_EDITBOX | BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE;
|
||||
LPCITEMIDLIST pFolder = SHBrowseForFolderA(&bi);
|
||||
if (pFolder == NULL) return "";
|
||||
if (!SHGetPathFromIDListA(pFolder, Buffer)) return "";
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
struct async_locker
|
||||
{
|
||||
async_locker() { async_lock(); }
|
||||
@@ -472,12 +488,14 @@ int main(int argc, char** argv)
|
||||
int frames = 0;
|
||||
float one_sec = 0;
|
||||
float render_timer = 0;
|
||||
float frame_timer = 0;
|
||||
while(running)
|
||||
{
|
||||
t1 = GetTickCount();
|
||||
float dt = (float)(t1 - t0) / 1000.0f;
|
||||
one_sec += dt;
|
||||
render_timer += dt;
|
||||
frame_timer += dt;
|
||||
t0 = t1;
|
||||
|
||||
if (one_sec > 1.f)
|
||||
@@ -507,20 +525,22 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> lock(render_mutex);
|
||||
if (render_timer > 1.0f / target_fps || App::I.redraw)
|
||||
if (render_timer > 1.0f / target_fps)
|
||||
{
|
||||
App::I.redraw = true;
|
||||
render_timer = 0;
|
||||
if (App::I.redraw)
|
||||
{
|
||||
async_lock();
|
||||
App::I.redraw = true;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
App::I.clear();
|
||||
App::I.update(dt);
|
||||
SwapBuffers(hDC);
|
||||
async_unlock();
|
||||
//LOG("swap main");
|
||||
}
|
||||
}
|
||||
if (App::I.redraw)
|
||||
{
|
||||
async_lock();
|
||||
App::I.redraw = true;
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
App::I.clear();
|
||||
App::I.update(frame_timer);
|
||||
SwapBuffers(hDC);
|
||||
async_unlock();
|
||||
frame_timer = 0;
|
||||
//LOG("swap main");
|
||||
}
|
||||
frames++;
|
||||
|
||||
|
||||
@@ -82,7 +82,11 @@ void NodeDialogBrowse::init_controls()
|
||||
LOG("change working path to %s", path.c_str());
|
||||
async_start();
|
||||
App::I.work_path = path;
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Destination dir: %s", path_buffer);
|
||||
search_path = path;
|
||||
clear_list();
|
||||
@@ -92,7 +96,11 @@ void NodeDialogBrowse::init_controls()
|
||||
});
|
||||
};
|
||||
working_path = find<NodeText>("path");
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(App::I.work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(App::I.work_path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
#endif
|
||||
// if (auto* first = (NodeDialogBrowseItem*)container->get_child_at(0))
|
||||
|
||||
@@ -202,14 +202,22 @@ void NodeDialogSave::init_controls()
|
||||
LOG("change working path to %s", path.c_str());
|
||||
async_start();
|
||||
App::I.work_path = path;
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
async_update();
|
||||
async_end();
|
||||
});
|
||||
};
|
||||
working_path = find<NodeText>("path");
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(App::I.work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(App::I.work_path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
#endif
|
||||
}
|
||||
@@ -258,14 +266,22 @@ void NodeDialogNewDoc::init_controls()
|
||||
LOG("change working path to %s", path.c_str());
|
||||
async_start();
|
||||
App::I.work_path = path;
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
async_update();
|
||||
async_end();
|
||||
});
|
||||
};
|
||||
working_path = find<NodeText>("path");
|
||||
#ifdef _WIN32
|
||||
GetFullPathNameA(App::I.work_path.c_str(), sizeof(path_buffer), path_buffer, nullptr);
|
||||
#else
|
||||
realpath(App::I.work_path.c_str(), path_buffer);
|
||||
#endif
|
||||
working_path->set_text_format("Working dir: %s", path_buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user