examples: Added documentation link.
This commit is contained in:
parent
cebb749752
commit
a5898b131b
@ -12,9 +12,6 @@
|
||||
#include "dialog.h"
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
extern "C" void* __stdcall GetModuleHandleA(const char* _moduleName);
|
||||
extern "C" uint32_t __stdcall GetModuleFileNameA(void* _module, char* _outFilePath, uint32_t _size);
|
||||
|
||||
typedef uintptr_t (__stdcall *LPOFNHOOKPROC)(void*, uint32_t, uintptr_t, uint64_t);
|
||||
|
||||
struct OPENFILENAMEA
|
||||
@ -44,10 +41,29 @@ struct OPENFILENAMEA
|
||||
uint32_t flagsEx;
|
||||
};
|
||||
|
||||
extern "C" bool __stdcall GetOpenFileNameA(OPENFILENAMEA* _ofn);
|
||||
extern "C" bool __stdcall GetOpenFileNameA(OPENFILENAMEA* _ofn);
|
||||
extern "C" void* __stdcall GetModuleHandleA(const char* _moduleName);
|
||||
extern "C" uint32_t __stdcall GetModuleFileNameA(void* _module, char* _outFilePath, uint32_t _size);
|
||||
extern "C" void* __stdcall ShellExecuteA(void* _hwnd, void* _operation, void* _file, void* _parameters, void* _directory, int32_t _showCmd);
|
||||
|
||||
#endif // BX_PLATFORM_WINDOWS
|
||||
|
||||
void openUrl(const bx::StringView& _url)
|
||||
{
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
ShellExecuteA(NULL, NULL, _url, NULL, NULL, false);
|
||||
#else
|
||||
char tmp[4096];
|
||||
# if BX_PLATFORM_OSX
|
||||
# define OPEN "open"
|
||||
# else
|
||||
# define OPEN "xdg-open"
|
||||
# endif // BX_PLATFORM_OSX
|
||||
bx::snprintf(tmp, BX_COUNTOF(tmp), OPEN " %.*s", _url.getLength(), _url.getPtr() );
|
||||
system(tmp);
|
||||
#endif // BX_PLATFORM_*
|
||||
}
|
||||
|
||||
class Split
|
||||
{
|
||||
public:
|
||||
|
@ -14,17 +14,20 @@ struct FileSelectionDialogType
|
||||
{
|
||||
Open,
|
||||
Save,
|
||||
|
||||
|
||||
Count
|
||||
};
|
||||
};
|
||||
|
||||
///
|
||||
bool openFileSelectionDialog(
|
||||
bx::FilePath& _inOutFilePath
|
||||
, FileSelectionDialogType::Enum _type
|
||||
, const bx::StringView& _title
|
||||
, const bx::StringView& _filter = "All Files | *"
|
||||
);
|
||||
bx::FilePath& _inOutFilePath
|
||||
, FileSelectionDialogType::Enum _type
|
||||
, const bx::StringView& _title
|
||||
, const bx::StringView& _filter = "All Files | *"
|
||||
);
|
||||
|
||||
///
|
||||
void openUrl(const bx::StringView& _url);
|
||||
|
||||
#endif // DIALOG_H_HEADER_GUARD
|
||||
|
@ -446,10 +446,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
return bx::kExitFailure;
|
||||
}
|
||||
|
||||
AppI::AppI(const char* _name, const char* _description)
|
||||
AppI::AppI(const char* _name, const char* _description, const char* _url)
|
||||
{
|
||||
m_name = _name;
|
||||
m_description = _description;
|
||||
m_url = _url;
|
||||
m_next = s_apps;
|
||||
|
||||
s_apps = this;
|
||||
@ -490,6 +491,11 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
return m_description;
|
||||
}
|
||||
|
||||
const char* AppI::getUrl() const
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
|
||||
AppI* AppI::getNext()
|
||||
{
|
||||
return m_next;
|
||||
|
@ -24,15 +24,15 @@ extern "C" int _main_(int _argc, char** _argv);
|
||||
#endif // ENTRY_CONFIG_IMPLEMENT_MAIN
|
||||
|
||||
#if ENTRY_CONFIG_IMPLEMENT_MAIN
|
||||
#define ENTRY_IMPLEMENT_MAIN(_app, _name, _description) \
|
||||
#define ENTRY_IMPLEMENT_MAIN(_app, ...) \
|
||||
int _main_(int _argc, char** _argv) \
|
||||
{ \
|
||||
_app app(_name, _description); \
|
||||
_app app(__VA_ARGS__); \
|
||||
return entry::runApp(&app, _argc, _argv); \
|
||||
}
|
||||
#else
|
||||
#define ENTRY_IMPLEMENT_MAIN(_app, _name, _description) \
|
||||
_app s_ ## _app ## App(_name, _description)
|
||||
#define ENTRY_IMPLEMENT_MAIN(_app, ...) \
|
||||
_app s_ ## _app ## App(__VA_ARGS__)
|
||||
#endif // ENTRY_CONFIG_IMPLEMENT_MAIN
|
||||
|
||||
namespace entry
|
||||
@ -282,7 +282,7 @@ namespace entry
|
||||
{
|
||||
public:
|
||||
///
|
||||
AppI(const char* _name, const char* _description);
|
||||
AppI(const char* _name, const char* _description, const char* _url = "https://bkaradzic.github.io/bgfx/index.html");
|
||||
|
||||
///
|
||||
virtual ~AppI() = 0;
|
||||
@ -302,6 +302,9 @@ namespace entry
|
||||
///
|
||||
const char* getDescription() const;
|
||||
|
||||
///
|
||||
const char* getUrl() const;
|
||||
|
||||
///
|
||||
AppI* getNext();
|
||||
|
||||
@ -310,6 +313,7 @@ namespace entry
|
||||
private:
|
||||
const char* m_name;
|
||||
const char* m_description;
|
||||
const char* m_url;
|
||||
};
|
||||
|
||||
///
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "imgui/imgui.h"
|
||||
#include "entry/entry.h"
|
||||
#include "entry/cmd.h"
|
||||
#include "entry/dialog.h"
|
||||
#include <bx/string.h>
|
||||
#include <bx/timer.h>
|
||||
#include <bx/math.h>
|
||||
@ -138,6 +139,16 @@ void showExampleDialog(entry::AppI* _app, const char* _errorText)
|
||||
ImGui::Begin(temp);
|
||||
|
||||
ImGui::TextWrapped("%s", _app->getDescription() );
|
||||
|
||||
bx::StringView url = _app->getUrl();
|
||||
if (!url.isEmpty() )
|
||||
{
|
||||
if (ImGui::Button("Documentation") )
|
||||
{
|
||||
openUrl(url);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
if (NULL != _errorText)
|
||||
|
@ -33,7 +33,6 @@ project ("example-common")
|
||||
path.join(BGFX_DIR, "3rdparty/dear-imgui/**.cpp"),
|
||||
path.join(BGFX_DIR, "3rdparty/dear-imgui/**.h"),
|
||||
path.join(BGFX_DIR, "examples/common/**.cpp"),
|
||||
path.join(BGFX_DIR, "examples/common/**.cpp"),
|
||||
path.join(BGFX_DIR, "examples/common/**.h"),
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,8 @@ function exampleProjectDefaults()
|
||||
}
|
||||
|
||||
links {
|
||||
"example-common",
|
||||
"example-glue",
|
||||
"example-common",
|
||||
"bgfx",
|
||||
"bimg_decode",
|
||||
"bimg",
|
||||
|
Loading…
Reference in New Issue
Block a user