Skip to content

Commit b41e136

Browse files
Initial Commit
0 parents  commit b41e136

File tree

13 files changed

+753
-0
lines changed

13 files changed

+753
-0
lines changed

.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.dub
2+
docs.json
3+
__dummy.html
4+
docs/
5+
/wsedit
6+
wsedit.so
7+
wsedit.dylib
8+
wsedit.dll
9+
wsedit.a
10+
wsedit.lib
11+
wsedit-test-*
12+
*.exe
13+
*.o
14+
*.obj
15+
*.lst
16+
dub.selections.json

COPYING

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Copyright © 2019, Cospec Games
2+
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4+
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6+
7+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8+
9+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Wereshift Scene Editor
2+
## Early Work-in-Progress
3+
4+
This repository contains the scene editor for Wereshift.
5+
It's still under heavy development, but progressing at a pretty decent pace.
6+

dub.sdl

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name "wsedit"
2+
description "Wereshift Level Editor"
3+
authors "Cospec Games" "Luna Nielsen"
4+
copyright "Copyright © 2019, Cospec Games"
5+
license "BSD 2-clause"
6+
dependency "sdlang-d" version="~>0.10.5"
7+
dependency "gfm" version="~>8.0.1"
8+
dependency "bindbc-opengl" version="~>0.9.0"
9+
dependency "imageformats" version="~>7.0.2"
10+
dependency "gtk-d" version="~>3.9.0"
11+
dependency "d-dazzle" version="~>1.0.1"
12+
dependency "wsfmt" version="~master"

res/wereshift.png

6.81 KB
Loading

source/app.d

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
Copyright © 2019, Cospec Games
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
*/
12+
import std.stdio;
13+
import dazzle.Application;
14+
import wsedit.windows.appwin;
15+
16+
int main(string[] args)
17+
{
18+
scope(failure) {
19+
// TODO: If a crash happens, make an autosave.
20+
}
21+
22+
Application app = new Application("dk.cospec.wsedit", GApplicationFlags.FLAGS_NONE);
23+
app.addOnActivate((appx) { new WSEditWindow(app); });
24+
return app.run(args);
25+
}

source/wsedit/helpers.d

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
Copyright © 2019, Cospec Games
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
*/
12+
module wsedit.helpers;
13+
import wsedit;
14+
import gtk.Window;
15+
public import gtk.MessageDialog;
16+
17+
/**
18+
Utility function to show message boxes
19+
20+
Imitates C#'s message boxes a little bit
21+
*/
22+
class MessageBox {
23+
static:
24+
/**
25+
Shows a message box.
26+
27+
Pango Markup is supported.
28+
https://developer.gnome.org/pygtk/stable/pango-markup-language.html
29+
*/
30+
int show(string message, GtkMessageType type = GtkMessageType.INFO, GtkButtonsType buttonType = GtkButtonsType.OK, Window win = null) {
31+
MessageDialog errDialog = new MessageDialog(
32+
win is null ? STATE.mainWindow : win,
33+
GtkDialogFlags.MODAL,
34+
type,
35+
buttonType,
36+
true,
37+
message);
38+
39+
scope(exit) errDialog.destroy();
40+
return errDialog.run();
41+
}
42+
}

source/wsedit/package.d

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
Copyright © 2019, Cospec Games
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
*/
12+
module wsedit;
13+
import gtk.Window;
14+
import wsf;
15+
16+
/**
17+
The model where the state is stored in
18+
*/
19+
struct StateModel {
20+
/// The file for the current scene
21+
string currentSceneFile;
22+
23+
/// The main app window
24+
Window mainWindow;
25+
26+
/// Wether the app is in fullscreen mode
27+
bool fullscreen;
28+
29+
/// The scene
30+
Scene* scene;
31+
32+
33+
/**
34+
Creates a new empty scene
35+
*/
36+
void createScene() {
37+
scene = new Scene;
38+
}
39+
}
40+
41+
/**
42+
The 2D camera in the workspace
43+
*/
44+
struct Camera2D {
45+
/**
46+
X coordinate
47+
*/
48+
double x = 0;
49+
50+
/**
51+
Y coordinate
52+
*/
53+
double y = 0;
54+
55+
/**
56+
Zoom level
57+
*/
58+
double zoom = 1;
59+
}
60+
61+
/**
62+
The global application state
63+
*/
64+
__gshared StateModel STATE;

source/wsedit/widgets/headerbar.d

+183
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/**
2+
Copyright © 2019, Cospec Games
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
*/
12+
module wsedit.widgets.headerbar;
13+
import gtk.HeaderBar;
14+
import gtk.Box;
15+
import gtk.Button;
16+
import gtk.Image;
17+
import gtk.Widget;
18+
import gtk.StyleContext;
19+
import gtk.EventBox;
20+
import gtk.Label;
21+
import gtk.Revealer;
22+
import gdk.Event;
23+
import gtk.Popover;
24+
import dazzle.EntryBox;
25+
import dazzle.PriorityBox;
26+
import dazzle.ApplicationWindow;
27+
import dazzle.MenuButton;
28+
29+
import gio.Menu;
30+
import gio.MenuItem;
31+
import gio.SimpleAction;
32+
33+
import gdk.Event;
34+
35+
import wsedit;
36+
import wsedit.helpers;
37+
import wsedit.windows.appwin;
38+
39+
class WSHeader : HeaderBar {
40+
private:
41+
WSEditWindow appwin;
42+
43+
/* I/O Section */
44+
MenuButton openButton;
45+
Button newButton;
46+
Button saveButton;
47+
Box ioBox;
48+
49+
/* Info Section */
50+
EventBox titleEventBox;
51+
EntryBox titleBox;
52+
Label titleLabel;
53+
Button buildButton;
54+
Button runButton;
55+
56+
/* Config Section */
57+
MenuButton settingsMenuButton;
58+
Button fullscreenButton;
59+
60+
/* Helper functions */
61+
62+
void buildLeftSection() {
63+
ioBox = new Box(Orientation.HORIZONTAL, 0);
64+
ioBox.getStyleContext().addClass("linked");
65+
66+
Menu openMenu = new Menu();
67+
68+
newButton = genButton("document-new-symbolic");
69+
newButton.addOnReleased((Button btn) {
70+
STATE.createScene();
71+
STATE.currentSceneFile = "unnamed.lvl";
72+
title = "Unnamed Level";
73+
appwin.workspace.queueDraw();
74+
});
75+
76+
openButton = new MenuButton("document-open-symbolic", openMenu);
77+
saveButton = genButton("document-save-symbolic");
78+
79+
ioBox.packStart(newButton, false, false, 0);
80+
ioBox.packStart(openButton, false, false, 0);
81+
ioBox.packStart(saveButton, false, false, 0);
82+
83+
this.packStart(ioBox);
84+
}
85+
86+
Widget buildMidsection() {
87+
88+
// First we generate all the changable widgets.
89+
buildButton = genButton("package-x-generic-symbolic");
90+
runButton = genButton("media-playback-start-symbolic");
91+
titleLabel = new Label("");
92+
93+
// Add the text entry (the box around the label)
94+
titleEventBox = new EventBox();
95+
titleBox = new EntryBox();
96+
titleBox.packStart(titleEventBox, false, false, 0);
97+
98+
titleEventBox.addOnButtonRelease((GdkEventButton* btn, Widget _) {
99+
100+
if (btn.button == 1) {
101+
MessageBox.show("This feature is not implemented, <i>yet</i>.");
102+
}
103+
104+
return true;
105+
});
106+
107+
titleEventBox.add(titleLabel);
108+
109+
// Create the priority box, add the linked style class to make the buttons and the entry box merge together.
110+
PriorityBox priority = new PriorityBox();
111+
priority.getStyleContext.addClass("linked");
112+
113+
// Pack it up and return it.
114+
priority.packStart(buildButton, false, false, 0);
115+
priority.packStart(titleBox, false, false, 0);
116+
priority.packStart(runButton, false, false, 0);
117+
return priority;
118+
}
119+
120+
void buildRightSection() {
121+
122+
fullscreenButton = genButton("view-fullscreen-symbolic");
123+
fullscreenButton.addOnReleased((Button _) {
124+
appwin.setFullscreen(!appwin.getFullscreen());
125+
STATE.fullscreen = appwin.getFullscreen();
126+
this.setShowCloseButton(!appwin.getFullscreen());
127+
(cast(Image)fullscreenButton.getImage()).setFromIconName(appwin.getFullscreen ? "view-restore-symbolic" : "view-fullscreen-symbolic", IconSize.MENU);
128+
});
129+
130+
Menu hamburgerModel = new Menu();
131+
hamburgerModel.append("About", "win.about-open");
132+
settingsMenuButton = new MenuButton("open-menu-symbolic", hamburgerModel);
133+
settingsMenuButton.setFocusOnClick(false);
134+
settingsMenuButton.setPopover(new Popover(settingsMenuButton, hamburgerModel));
135+
136+
this.packEnd(fullscreenButton);
137+
this.packEnd(settingsMenuButton);
138+
}
139+
140+
Button genButton(string imgSym) {
141+
Button btn = new Button();
142+
btn.setImage(new Image(imgSym, IconSize.MENU));
143+
return btn;
144+
}
145+
146+
public:
147+
/// Constructor
148+
this(WSEditWindow appwin) {
149+
this.appwin = appwin;
150+
this.setShowCloseButton(true);
151+
152+
// Build all the window controls
153+
this.buildLeftSection();
154+
this.setCustomTitle(buildMidsection());
155+
this.buildRightSection();
156+
157+
title = "";
158+
159+
this.showAll();
160+
}
161+
162+
/**
163+
Gets the current window title
164+
*/
165+
@property string title() {
166+
return titleLabel.getText();
167+
}
168+
169+
/**
170+
Sets the current window title
171+
*/
172+
@property void title(string name) {
173+
string wname = name.length == 0 ? "Wereshift Scene Editor" : "Wereshift Scene Editor: " ~ name;
174+
175+
// Set the systemwide window title
176+
appwin.setName(wname);
177+
appwin.setTitle(wname);
178+
appwin.setWmclass(wname, "WSEdit");
179+
180+
// Set the title label.
181+
titleLabel.setText(name.length == 0 ? "Wereshift Scene Editor" : name);
182+
}
183+
}

source/wsedit/widgets/package.d

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
Copyright © 2019, Cospec Games
3+
4+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5+
6+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7+
8+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9+
10+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
11+
*/
12+
module wsedit.widgets;
13+
public import wsedit.widgets.headerbar;
14+
public import wsedit.widgets.workspace;

0 commit comments

Comments
 (0)