Skip to content

Commit 319aef9

Browse files
Broke viewport, added tile selection
1 parent 55e0583 commit 319aef9

27 files changed

+1537
-455
lines changed

dub.sdl

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ description "Wereshift Level Editor"
33
authors "Cospec Games" "Luna Nielsen"
44
copyright "Copyright © 2019, Cospec Games"
55
license "BSD 2-clause"
6-
dependency "wsfmt" version="~master"
7-
dependency "gtk-d" version="~>3.9.0"
86
dependency "sdlang-d" version="~>0.10.5"
7+
dependency "dcontain" version="~>1.0.3"
8+
dependency "gtk-d" version="~>3.9.0"
9+
dependency "wsf" version="~master"
910
dependency "d-dazzle" version="~>1.0.1"
10-
dependency "d-handy" version="~>0.0.11"
11+
dependency "ppc" version="~>0.2.6"
12+
stringImportPaths "res/" "stylesheets/"
File renamed without changes.

res/x_tiles/simpleTileset_orange.png

66.9 KB
Loading

source/wsedit/fmt/package.d

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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.fmt;
13+
public import wsedit.fmt.project;
14+
public import wsedit.fmt.resource;
15+
public import wsedit.fmt.scene;
16+
public import wsedit.fmt.tile;

source/wsedit/fmt/project.d

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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.fmt.project;
13+
import wsf.serialization;
14+
import std.file;
15+
import wsedit.fmt.resource;
16+
import std.algorithm.searching : endsWith;
17+
18+
/**
19+
Creates a new project
20+
*/
21+
WSEProject newProject(string name, string path, WSESceneInfo info) {
22+
WSEProject project;
23+
project.name = name;
24+
project.path = path;
25+
project.sceneInfo = info;
26+
return project;
27+
}
28+
29+
/**
30+
Loads a WereShift Editor Project
31+
*/
32+
WSEProject loadProject(string file) {
33+
auto project = deserializeWSF!WSEProject(Tag.parseFile(file));
34+
project.path = file;
35+
return project;
36+
}
37+
38+
/**
39+
Build a WereShift Editor Project
40+
*/
41+
void saveProject(WSEProject project, string file) {
42+
Tag tag = serializeWSF!WSEProject(project);
43+
tag.buildFile(file.endsWith(".wsp") ? file : file~".wsp");
44+
}
45+
46+
/**
47+
A wereshift editor project file
48+
*/
49+
struct WSEProject {
50+
51+
/**
52+
Name of the project
53+
*/
54+
string name;
55+
56+
/**
57+
Path to save the project to
58+
*/
59+
@ignore
60+
string path;
61+
62+
/**
63+
List of resources
64+
*/
65+
WSEResource[] resources;
66+
67+
/**
68+
Information about the scene
69+
*/
70+
WSESceneInfo sceneInfo;
71+
72+
/**
73+
Information about the tiles in the tileset
74+
*/
75+
WSETilesetInfo[] tilesetInfo;
76+
77+
void save(string file = null) {
78+
saveProject(this, file is null ? path : file);
79+
}
80+
}
81+
82+
/**
83+
Relevant scene info
84+
*/
85+
struct WSESceneInfo {
86+
/**
87+
Width of scene in tiles
88+
*/
89+
uint width;
90+
91+
/**
92+
Height of scene in tiles
93+
*/
94+
uint height;
95+
96+
/**
97+
Width of a single tile
98+
*/
99+
uint tileWidth;
100+
101+
/**
102+
Height of a single tile
103+
*/
104+
uint tileHeight;
105+
}
106+
107+
/**
108+
Information about a tileset tile
109+
*/
110+
struct WSETilesetInfo {
111+
/**
112+
The X index of the tile in the tilesheet
113+
*/
114+
uint tileX;
115+
116+
/**
117+
The Y Index of the tile in the tilesheet
118+
*/
119+
uint tileY;
120+
}

source/wsedit/fmt/resource.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.fmt.resource;
13+
14+
/**
15+
A type of a resource
16+
*/
17+
enum ResourceType {
18+
Tileset,
19+
ActorDatabase,
20+
Dialogue,
21+
Translation
22+
}
23+
24+
/**
25+
A wereshift editor resource
26+
*/
27+
struct WSEResource {
28+
/**
29+
The ID of the resource
30+
*/
31+
string resourceId;
32+
33+
/**
34+
The type of the resource
35+
*/
36+
ResourceType type;
37+
38+
/**
39+
The path to the resource file
40+
*/
41+
string path;
42+
}

source/wsedit/widgets/pages/package.d renamed to source/wsedit/fmt/scene.d

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
1010
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.
1111
*/
12-
module wsedit.widgets.pages;
13-
public import wsedit.widgets.pages.newscene;
14-
public import wsedit.widgets.pages.workspace;
12+
module wsedit.fmt.scene;
13+
14+
/**
15+
The structure for a Wereshift scene
16+
*/
17+
struct WSEScene {
18+
19+
}

source/wsedit/fmt/tile.d

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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.fmt.tile;
13+
14+
/**
15+
A wereshift tile
16+
*/
17+
struct WSETile {
18+
19+
}

source/wsedit/helpers.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ static:
4747
string buildPathForScene(string name) {
4848
import std.format : format;
4949
import std.array : replace;
50-
return name.length == 0 ? "" : "%s.wsf".format(name.replace(" ", "_"));
50+
return name.length == 0 ? "" : "%s.wsp".format(name.replace(" ", "_"));
5151
}

source/wsedit/package.d

+3-32
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*/
1212
module wsedit;
1313
import gtk.Window;
14-
import wsf;
14+
import wsf.spec.scene;
15+
import wsedit.subsystem.tilemgr;
16+
import wsedit.fmt;
1517

1618
/**
1719
The currently "selected" index
@@ -42,43 +44,12 @@ struct Selection {
4244
The model where the state is stored in
4345
*/
4446
struct StateModel {
45-
/// The file for the current scene
46-
string currentSceneFile;
4747

4848
/// The main app window
4949
Window mainWindow;
5050

5151
/// Wether the app is in fullscreen mode
5252
bool fullscreen;
53-
54-
/// The scene
55-
Scene* scene;
56-
57-
/**
58-
Width of tile
59-
*/
60-
int tileWidth = 32;
61-
62-
/**
63-
Height of tile
64-
*/
65-
int tileHeight = 32;
66-
67-
/**
68-
The current selection
69-
*/
70-
Selection selection;
71-
72-
73-
/**
74-
Creates a new empty scene
75-
*/
76-
void createScene(string name, int width, int height) {
77-
scene = new Scene;
78-
scene.width = width;
79-
scene.height = height;
80-
scene.name = name;
81-
}
8253
}
8354

8455
/**

source/wsedit/pages/initpage.d

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module wsedit.pages.initpage;
2+
import wsedit.subsystem.wsrenderer;
3+
import gtk.DrawingArea;
4+
import gdk.Cairo;
5+
import cairo.Context;
6+
7+
/**
8+
The first page seen when the application is started
9+
*/
10+
class WSPageInit : DrawingArea {
11+
private:
12+
Renderer renderer;
13+
14+
public:
15+
16+
/**
17+
Creates the init page
18+
*/
19+
this() {
20+
super(512, 512);
21+
renderer = new Renderer(this);
22+
23+
this.addOnDraw((Scoped!Context ctx, _) {
24+
return renderer.renderLogo(ctx, "No scene loaded!");
25+
});
26+
27+
28+
}
29+
}

0 commit comments

Comments
 (0)