Skip to content

Commit 21cf9aa

Browse files
author
Ravbug
committed
Add a way to choose target platform when opening a project
Fix #27
1 parent 4b9a518 commit 21cf9aa

File tree

6 files changed

+129
-16
lines changed

6 files changed

+129
-16
lines changed

source/form.fbp

+74-7
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
<object class="notebookpage" expanded="1">
123123
<property name="bitmap"></property>
124124
<property name="label">Projects</property>
125-
<property name="select">0</property>
125+
<property name="select">1</property>
126126
<object class="wxPanel" expanded="1">
127127
<property name="BottomDockable">1</property>
128128
<property name="LeftDockable">1</property>
@@ -703,7 +703,7 @@
703703
<object class="notebookpage" expanded="1">
704704
<property name="bitmap"></property>
705705
<property name="label">Editor Versions</property>
706-
<property name="select">1</property>
706+
<property name="select">0</property>
707707
<object class="wxPanel" expanded="1">
708708
<property name="BottomDockable">1</property>
709709
<property name="LeftDockable">1</property>
@@ -3093,7 +3093,7 @@
30933093
</object>
30943094
</object>
30953095
</object>
3096-
<object class="Dialog" expanded="0">
3096+
<object class="Dialog" expanded="1">
30973097
<property name="aui_managed">0</property>
30983098
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
30993099
<property name="bg"></property>
@@ -3120,7 +3120,7 @@
31203120
<property name="window_extra_style"></property>
31213121
<property name="window_name"></property>
31223122
<property name="window_style"></property>
3123-
<object class="wxGridBagSizer" expanded="0">
3123+
<object class="wxGridBagSizer" expanded="1">
31243124
<property name="empty_cell_size"></property>
31253125
<property name="flexible_direction">wxBOTH</property>
31263126
<property name="growablecols">0</property>
@@ -3261,14 +3261,81 @@
32613261
<property name="window_style"></property>
32623262
</object>
32633263
</object>
3264-
<object class="gbsizeritem" expanded="0">
3264+
<object class="gbsizeritem" expanded="1">
32653265
<property name="border">5</property>
32663266
<property name="colspan">1</property>
32673267
<property name="column">2</property>
3268-
<property name="flag">wxEXPAND</property>
3268+
<property name="flag">wxALL|wxALIGN_RIGHT</property>
32693269
<property name="row">2</property>
32703270
<property name="rowspan">1</property>
3271-
<object class="wxBoxSizer" expanded="0">
3271+
<object class="wxChoice" expanded="1">
3272+
<property name="BottomDockable">1</property>
3273+
<property name="LeftDockable">1</property>
3274+
<property name="RightDockable">1</property>
3275+
<property name="TopDockable">1</property>
3276+
<property name="aui_layer"></property>
3277+
<property name="aui_name"></property>
3278+
<property name="aui_position"></property>
3279+
<property name="aui_row"></property>
3280+
<property name="best_size"></property>
3281+
<property name="bg"></property>
3282+
<property name="caption"></property>
3283+
<property name="caption_visible">1</property>
3284+
<property name="center_pane">0</property>
3285+
<property name="choices">&quot;Current Platform&quot; &quot;Windows&quot; &quot;macOS&quot; &quot;Linux&quot; &quot;iOS&quot; &quot;Android&quot; &quot;WebGL&quot; &quot;UWP&quot;</property>
3286+
<property name="close_button">1</property>
3287+
<property name="context_help"></property>
3288+
<property name="context_menu">1</property>
3289+
<property name="default_pane">0</property>
3290+
<property name="dock">Dock</property>
3291+
<property name="dock_fixed">0</property>
3292+
<property name="docking">Left</property>
3293+
<property name="enabled">1</property>
3294+
<property name="fg"></property>
3295+
<property name="floatable">1</property>
3296+
<property name="font"></property>
3297+
<property name="gripper">0</property>
3298+
<property name="hidden">0</property>
3299+
<property name="id">wxID_ANY</property>
3300+
<property name="max_size"></property>
3301+
<property name="maximize_button">0</property>
3302+
<property name="maximum_size"></property>
3303+
<property name="min_size"></property>
3304+
<property name="minimize_button">0</property>
3305+
<property name="minimum_size"></property>
3306+
<property name="moveable">1</property>
3307+
<property name="name">platformChooser</property>
3308+
<property name="pane_border">1</property>
3309+
<property name="pane_position"></property>
3310+
<property name="pane_size"></property>
3311+
<property name="permission">protected</property>
3312+
<property name="pin_button">1</property>
3313+
<property name="pos"></property>
3314+
<property name="resize">Resizable</property>
3315+
<property name="selection">0</property>
3316+
<property name="show">1</property>
3317+
<property name="size"></property>
3318+
<property name="style"></property>
3319+
<property name="subclass">; ; forward_declare</property>
3320+
<property name="toolbar_pane">0</property>
3321+
<property name="tooltip"></property>
3322+
<property name="validator_data_type"></property>
3323+
<property name="validator_style">wxFILTER_NONE</property>
3324+
<property name="validator_type">wxDefaultValidator</property>
3325+
<property name="validator_variable"></property>
3326+
<property name="window_extra_style"></property>
3327+
<property name="window_name"></property>
3328+
<property name="window_style"></property>
3329+
</object>
3330+
</object>
3331+
<object class="gbsizeritem" expanded="1">
3332+
<property name="border">5</property>
3333+
<property name="colspan">1</property>
3334+
<property name="column">2</property>
3335+
<property name="flag">wxEXPAND</property>
3336+
<property name="row">3</property>
3337+
<property name="rowspan">1</property>
3338+
<object class="wxBoxSizer" expanded="1">
32723339
<property name="minimum_size"></property>
32733340
<property name="name">dialogSizer</property>
32743341
<property name="orient">wxHORIZONTAL</property>

source/interface.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
7070
projects_pane->SetSizer( projectManSizer );
7171
projects_pane->Layout();
7272
projectManSizer->Fit( projects_pane );
73-
notebook->AddPage( projects_pane, wxT("Projects"), false );
73+
notebook->AddPage( projects_pane, wxT("Projects"), true );
7474
wxPanel* installs_pane;
7575
installs_pane = new wxPanel( notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
7676
wxGridBagSizer* MainSizer;
@@ -149,7 +149,7 @@ MainFrame::MainFrame( wxWindow* parent, wxWindowID id, const wxString& title, co
149149
installs_pane->SetSizer( MainSizer );
150150
installs_pane->Layout();
151151
MainSizer->Fit( installs_pane );
152-
notebook->AddPage( installs_pane, wxT("Editor Versions"), true );
152+
notebook->AddPage( installs_pane, wxT("Editor Versions"), false );
153153

154154
main_sizer->Add( notebook, 1, wxEXPAND | wxALL, 5 );
155155

@@ -371,6 +371,12 @@ OpenWithEditorDlgBase::OpenWithEditorDlgBase( wxWindow* parent, wxWindowID id, c
371371
editorsListBox = new wxListBox( this, VERSIONS_LIST, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_NEEDED_SB|wxLB_SINGLE );
372372
openWithSizer->Add( editorsListBox, wxGBPosition( 1, 0 ), wxGBSpan( 1, 3 ), wxALL|wxEXPAND, 5 );
373373

374+
wxString platformChooserChoices[] = { wxT("Current Platform"), wxT("Windows"), wxT("macOS"), wxT("Linux"), wxT("iOS"), wxT("Android"), wxT("WebGL"), wxT("UWP") };
375+
int platformChooserNChoices = sizeof( platformChooserChoices ) / sizeof( wxString );
376+
platformChooser = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, platformChooserNChoices, platformChooserChoices, 0 );
377+
platformChooser->SetSelection( 0 );
378+
openWithSizer->Add( platformChooser, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxALL|wxALIGN_RIGHT, 5 );
379+
374380
wxBoxSizer* dialogSizer;
375381
dialogSizer = new wxBoxSizer( wxHORIZONTAL );
376382

@@ -384,7 +390,7 @@ OpenWithEditorDlgBase::OpenWithEditorDlgBase( wxWindow* parent, wxWindowID id, c
384390
dialogSizer->Add( openBtn, 0, wxALL, 5 );
385391

386392

387-
openWithSizer->Add( dialogSizer, wxGBPosition( 2, 2 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
393+
openWithSizer->Add( dialogSizer, wxGBPosition( 3, 2 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 );
388394

389395

390396
openWithSizer->AddGrowableCol( 0 );

source/interface.h

+1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class OpenWithEditorDlgBase : public wxDialog
143143
protected:
144144
wxStaticText* openWithLabel;
145145
wxListBox* editorsListBox;
146+
wxChoice* platformChooser;
146147
wxButton* openBtn;
147148

148149
public:

source/interface_derived.cpp

+28-3
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ void MainFrameDerived::OnOpenWith(wxCommandEvent& event){
359359
long selectedIndex = wxListCtrl_get_selected(projectsList);
360360
if (selectedIndex > -1){
361361
project& p = projects[selectedIndex];
362-
OpenWithCallback c = [&](project p, editor e){
362+
OpenWithCallback c = [&](project p, editor e, TargetPlatform plat){
363363
//open the project
364-
OpenProject(p,e);
364+
OpenProject(p,e, plat);
365365
};
366366

367367
OpenWithDlg* dlg = new OpenWithDlg(this,p,editors,c);
@@ -421,13 +421,38 @@ void MainFrameDerived::OpenProject(const long& index){
421421
MainFrameDerived::OnOpenWith(evt);
422422
}
423423

424+
const char* const PlatToStr(TargetPlatform plat) {
425+
switch (plat) {
426+
case TargetPlatform::CurrentPlatform:
427+
return "";
428+
case TargetPlatform::Windows:
429+
return "win64";
430+
case TargetPlatform::macOS:
431+
return "osxuniversal";
432+
case TargetPlatform::Linux:
433+
return "linux64";
434+
case TargetPlatform::iOS:
435+
return "ios";
436+
case TargetPlatform::Android:
437+
return "android";
438+
case TargetPlatform::WebGL:
439+
return "webgl";
440+
case TargetPlatform::UWP:
441+
return "windowsstoreapps";
442+
}
443+
}
444+
424445
/**
425446
Open a specific project with a specific editor
426447
@param p the project to open
427448
@param e the editor version to use when opening the project
428449
*/
429-
void MainFrameDerived::OpenProject(const project& p, const editor& e){
450+
void MainFrameDerived::OpenProject(const project& p, const editor& e, TargetPlatform plat){
430451
string cmd = "\"" + (e.path / e.name / executable).string() + "\" -projectpath \"" + p.path.string() + "\"";
452+
if (plat != TargetPlatform::CurrentPlatform) {
453+
auto str = PlatToStr(plat);
454+
cmd += std::format(" -buildTarget {}", str);
455+
}
431456
launch_process(cmd);
432457
}
433458

source/interface_derived.hpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@
2121
#include "wxlin.xpm"
2222
#endif
2323

24+
enum class TargetPlatform : uint8_t {
25+
CurrentPlatform,
26+
Windows,
27+
macOS,
28+
Linux,
29+
iOS,
30+
Android,
31+
WebGL,
32+
UWP
33+
};
34+
2435
class MainFrameDerived : public MainFrame{
2536
public:
2637
//constructor (takes no args)
@@ -33,7 +44,7 @@ class MainFrameDerived : public MainFrame{
3344
project LoadProject(const std::filesystem::path& path);
3445
void SaveProjects();
3546
void OpenProject(const long& index);
36-
void OpenProject(const project& p, const editor& e);
47+
void OpenProject(const project& p, const editor& e, TargetPlatform plat = TargetPlatform::CurrentPlatform);
3748
void SaveEditorVersions();
3849
void LoadEditorPath(const std::filesystem::path& path);
3950
void LoadEditorVersions();
@@ -194,7 +205,7 @@ class CreateProjectDialogD : public CreateProjectDialog{
194205
wxDECLARE_EVENT_TABLE();
195206
};
196207

197-
typedef std::function<void(const project&, const editor&)> OpenWithCallback;
208+
typedef std::function<void(const project&, const editor&, TargetPlatform platform)> OpenWithCallback;
198209
class OpenWithDlg : public OpenWithEditorDlgBase{
199210
public:
200211
OpenWithDlg(wxWindow* parent, const project& project, const std::vector<editor>& versions, const OpenWithCallback& callback);

source/open_with_dlg.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@ OpenWithDlg::OpenWithDlg(wxWindow* parent, const project& project, const vector<
3939
Called when the Open button in the dialog is pressed
4040
*/
4141
void OpenWithDlg::OnOpen(wxCommandEvent& event){
42+
// get the target platform
43+
const auto plat = TargetPlatform(platformChooser->GetSelection());
44+
4245
long selectedIndex = editorsListBox->GetSelection();
4346
if (selectedIndex != wxNOT_FOUND){
4447
editor e = editors[selectedIndex];
45-
callback(p,e);
48+
callback(p,e, plat);
4649
//close and dispose self
4750
this->EndModal(0);
4851
this->Destroy();

0 commit comments

Comments
 (0)