Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
T
TiledToOrx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
Sausage
TiledToOrx
Commits
61d8bf31
Commit
61d8bf31
authored
4 years ago
by
Miklós Mayer
Browse files
Options
Downloads
Patches
Plain Diff
Import ObjectType for each tile in a TileSet
parent
52a33eff
No related branches found
No related tags found
1 merge request
!2
Export new properties
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
TiledToOrx.Core/Engine.cs
+22
-3
22 additions, 3 deletions
TiledToOrx.Core/Engine.cs
TiledToOrx.Core/Map.cs
+19
-8
19 additions, 8 deletions
TiledToOrx.Core/Map.cs
TiledToOrx.Core/Tile.cs
+1
-0
1 addition, 0 deletions
TiledToOrx.Core/Tile.cs
with
42 additions
and
11 deletions
TiledToOrx.Core/Engine.cs
+
22
−
3
View file @
61d8bf31
...
...
@@ -39,6 +39,7 @@ namespace TiledToOrx.Core
Map
map
=
SerialiseToMap
(
reader
);
ISet
<
string
>
objectTypes
=
new
HashSet
<
string
>();
List
<
TileSet
>
externalTileSets
=
new
List
<
TileSet
>();
foreach
(
TileSet
tileset
in
map
.
tileSets
)
...
...
@@ -47,6 +48,13 @@ namespace TiledToOrx.Core
{
TileSet
tileSetPortion
=
ConvertExternalTileSetFile
(
filePath
,
tileset
.
source
);
externalTileSets
.
Add
(
tileSetPortion
);
foreach
(
TileSet
.
TileSetTile
tile
in
tileSetPortion
.
tiles
)
{
if
(
tile
.
objectType
!=
null
)
{
objectTypes
.
Add
(
tile
.
objectType
);
}
}
}
}
...
...
@@ -60,7 +68,7 @@ namespace TiledToOrx.Core
if
(
Errors
.
Length
==
0
)
{
CreateGraphicEntries
(
sb
,
map
,
mapOnly
,
oneBasedIndex
?
0
:
-
1
);
CreateGraphicEntries
(
sb
,
map
,
objectTypes
,
mapOnly
,
oneBasedIndex
?
0
:
-
1
);
}
}
...
...
@@ -114,7 +122,7 @@ namespace TiledToOrx.Core
return
"NONE"
;
//return blank if no tile defined. ERROR RETURNS ?
}
public
void
CreateGraphicEntries
(
StringBuilder
sb
,
Map
map
,
bool
mapOnly
,
int
plusIndex
)
public
void
CreateGraphicEntries
(
StringBuilder
sb
,
Map
map
,
ISet
<
string
>
objectTypes
,
bool
mapOnly
,
int
plusIndex
)
{
HashSet
<
Tile
>
tilesInUse
=
new
HashSet
<
Tile
>();
...
...
@@ -137,6 +145,10 @@ namespace TiledToOrx.Core
if
(
layer
.
data
.
mapData
.
Contains
(
tile
.
index
))
{
// This is probably not efficient, but I don't know how to parse the XML list into a HashMap, where the id attribute becomes the key
TileSet
.
TileSetTile
setTile
=
tileSet
.
tiles
.
Find
(
t
=>
t
.
id
+
tileSet
.
firstgid
+
1
==
tile
.
index
);
tile
.
objectType
=
setTile
!=
null
?
setTile
.
objectType
:
"DefaultTile"
;
tilesInUse
.
Add
(
tile
);
}
}
...
...
@@ -182,6 +194,13 @@ namespace TiledToOrx.Core
sb
.
AppendLine
(
FormatConfigHeading
(
"DefaultTile"
));
sb
.
AppendLine
(
""
);
//all the objects from the tilesets
foreach
(
string
type
in
objectTypes
)
{
sb
.
AppendLine
(
FormatConfigHeading
(
type
));
sb
.
AppendLine
(
""
);
}
//Output object sections
foreach
(
Tile
tile
in
tilesInUse
)
{
...
...
@@ -191,7 +210,7 @@ namespace TiledToOrx.Core
return
;
}
sb
.
AppendLine
(
FormatConfigHeading
(
tile
.
TileSetName
+
(
tile
.
index
+
plusIndex
).
ToString
()
+
AT
+
"Defaul
t
Tile"
));
sb
.
AppendLine
(
FormatConfigHeading
(
tile
.
TileSetName
+
(
tile
.
index
+
plusIndex
).
ToString
()
+
AT
+
(
tile
.
objectType
!=
null
?
tile
.
objectType
:
"DefaulTile"
))
)
;
string
graphic
=
tile
.
TileSetName
+
(
tile
.
index
+
plusIndex
).
ToString
()
+
"Graphic"
;
sb
.
AppendLine
(
FormatConfigProperty
(
"Graphic"
,
graphic
));
...
...
This diff is collapsed.
Click to expand it.
TiledToOrx.Core/Map.cs
+
19
−
8
View file @
61d8bf31
...
...
@@ -57,6 +57,17 @@ namespace TiledToOrx.Core
public
Image
image
;
[
XmlAttribute
(
AttributeName
=
"source"
)]
public
string
source
;
[
XmlElement
(
ElementName
=
"tile"
)]
public
List
<
TileSetTile
>
tiles
;
[
XmlRoot
(
"tile"
)]
public
class
TileSetTile
{
[
XmlAttribute
(
AttributeName
=
"id"
)]
public
int
id
;
[
XmlAttribute
(
AttributeName
=
"type"
)]
public
string
objectType
;
}
}
[
XmlRoot
(
"layer"
)]
...
...
@@ -70,20 +81,20 @@ namespace TiledToOrx.Core
public
int
height
;
[
XmlElement
(
ElementName
=
"data"
)]
public
Data
data
;
}
[
XmlRoot
(
"tile"
)]
public
class
XmlTile
{
[
XmlAttribute
(
AttributeName
=
"gid"
)]
public
int
gid
;
[
XmlRoot
(
"tile"
)]
public
class
LayerTile
{
[
XmlAttribute
(
AttributeName
=
"gid"
)]
public
int
gid
;
}
}
[
XmlRoot
(
"data"
)]
public
class
Data
{
private
List
<
Int64
>
_mapData
=
new
List
<
Int64
>();
private
List
<
Xml
Tile
>
_tileData
=
new
List
<
Xml
Tile
>();
//when map is xml format
private
List
<
Layer
.
Layer
Tile
>
_tileData
=
new
List
<
Layer
.
Layer
Tile
>();
//when map is xml format
private
string
_textData
=
""
;
[
XmlAttribute
(
AttributeName
=
"encoding"
)]
...
...
@@ -102,7 +113,7 @@ namespace TiledToOrx.Core
/// This is for when the tile map is supplied in XML format
/// </summary>
[
XmlElement
(
ElementName
=
"tile"
)]
public
List
<
Xml
Tile
>
tiles
;
public
List
<
Layer
.
Layer
Tile
>
tiles
;
/// <summary>
/// This is for when the tile map is supplied in csv, base64, gzip or zlib formats
...
...
This diff is collapsed.
Click to expand it.
TiledToOrx.Core/Tile.cs
+
1
−
0
View file @
61d8bf31
...
...
@@ -6,5 +6,6 @@
public
int
X
{
get
;
set
;
}
public
int
Y
{
get
;
set
;
}
public
string
TileSetName
{
get
;
set
;
}
public
string
objectType
{
get
;
set
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment