Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
itdan3344
stb
提交
85c836f3
S
stb
项目概览
itdan3344
/
stb
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
stb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
85c836f3
编写于
4月 15, 2015
作者:
S
Sean Barrett
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'work2'
上级
0d7f3bb6
6cb8c1b6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
9 deletion
+27
-9
stb_tilemap_editor.h
stb_tilemap_editor.h
+27
-9
未找到文件。
stb_tilemap_editor.h
浏览文件 @
85c836f3
// stb_tilemap_editor.h - v0.3
0
- Sean Barrett - http://nothings.org/stb
// stb_tilemap_editor.h - v0.3
5
- Sean Barrett - http://nothings.org/stb
// placed in the public domain - not copyrighted - first released 2014-09
//
// Embeddable tilemap editor for C/C++
...
...
@@ -275,6 +275,10 @@
// either approach allows cut&pasting between levels.)
//
// REVISION HISTORY
// 0.35 layername button changes
// - layername buttons grow with the layer panel
// - fix stbte_create_map being declared as stbte_create
// - fix declaration of stbte_create_map
// 0.30 properties release
// - properties panel for editing user-defined "object" properties
// - can link each tile to one other tile
...
...
@@ -296,11 +300,11 @@
// Support STBTE_HITTEST_TILE above
// ?Cancel drags by clicking other button? - may be fixed
// Finish support for toolbar at side
// Layer name buttons grow to fill box
//
// CREDITS
//
// Written by Sean Barrett, September & October 2014.
// Contributions from Josh Huelsman, January 2015.
//
// LICENSE
//
...
...
@@ -339,7 +343,7 @@ enum
// creation
//
extern
stbte_tilemap
*
stbte_create
(
int
map_x
,
int
map_y
,
int
map_layers
,
int
spacing_x
,
int
spacing_y
,
int
max_tiles
);
extern
stbte_tilemap
*
stbte_create
_map
(
int
map_x
,
int
map_y
,
int
map_layers
,
int
spacing_x
,
int
spacing_y
,
int
max_tiles
);
// create an editable tilemap
// map_x : dimensions of map horizontally (user can change this in editor), <= STBTE_MAX_TILEMAP_X
// map_y : dimensions of map vertically (user can change this in editor) <= STBTE_MAX_TILEMAP_Y
...
...
@@ -352,7 +356,7 @@ extern stbte_tilemap *stbte_create(int map_x, int map_y, int map_layers, int spa
extern
void
stbte_define_tile
(
stbte_tilemap
*
tm
,
unsigned
short
id
,
unsigned
int
layermask
,
const
char
*
category
);
// call this repeatedly for each tile to install the tile definitions into the editable tilemap
// tm : tilemap created by stbte_create
// tm : tilemap created by stbte_create
_map
// id : unique identifier for each tile, 0 <= id < 32768
// layermask : bitmask of which layers tile is allowed on: 1 = layer 0, 255 = layers 0..7
// (note that onscreen, the editor numbers the layers from 1 not 0)
...
...
@@ -938,6 +942,7 @@ struct stbte_tilemap
int
tileinfo_dirty
;
stbte__layer
layerinfo
[
STBTE_MAX_LAYERS
];
int
has_layer_names
;
int
layername_width
;
int
layer_scroll
;
int
propmode
;
int
solo_layer
;
...
...
@@ -1016,6 +1021,7 @@ stbte_tilemap *stbte_create_map(int map_x, int map_y, int map_layers, int spacin
tm
->
layer_scroll
=
0
;
tm
->
propmode
=
0
;
tm
->
has_layer_names
=
0
;
tm
->
layername_width
=
0
;
tm
->
undo_available_valid
=
0
;
for
(
i
=
0
;
i
<
tm
->
num_layers
;
++
i
)
{
...
...
@@ -1088,12 +1094,17 @@ void stbte_define_tile(stbte_tilemap *tm, unsigned short id, unsigned int layerm
tm
->
tileinfo_dirty
=
1
;
}
static
int
stbte__text_width
(
const
char
*
str
);
void
stbte_set_layername
(
stbte_tilemap
*
tm
,
int
layer
,
const
char
*
layername
)
{
STBTE_ASSERT
(
layer
>=
0
&&
layer
<
tm
->
num_layers
);
if
(
layer
>=
0
&&
layer
<
tm
->
num_layers
)
{
int
width
;
tm
->
layerinfo
[
layer
].
name
=
layername
;
tm
->
has_layer_names
=
1
;
width
=
stbte__text_width
(
layername
);
tm
->
layername_width
=
(
width
>
tm
->
layername_width
?
width
:
tm
->
layername_width
);
}
}
...
...
@@ -3382,14 +3393,21 @@ static void stbte__info(stbte_tilemap *tm, int x0, int y0, int w, int h)
static
void
stbte__layers
(
stbte_tilemap
*
tm
,
int
x0
,
int
y0
,
int
w
,
int
h
)
{
int
i
,
y
,
n
;
int
x1
=
x0
+
w
;
int
y1
=
y0
+
h
;
int
xoff
=
tm
->
has_layer_names
?
50
:
20
;
static
char
*
propmodes
[
3
]
=
{
"default"
,
"always"
,
"never"
};
int
num_rows
;
int
i
,
y
,
n
;
int
x1
=
x0
+
w
;
int
y1
=
y0
+
h
;
int
xoff
=
20
;
if
(
tm
->
has_layer_names
)
{
int
side
=
stbte__ui
.
panel
[
STBTE__panel_layers
].
side
;
xoff
=
stbte__region
[
side
].
width
-
42
;
xoff
=
(
xoff
<
tm
->
layername_width
+
10
?
xoff
:
tm
->
layername_width
+
10
);
}
x0
+=
2
;
y0
+=
5
;
if
(
!
tm
->
has_layer_names
)
{
...
...
@@ -3427,7 +3445,7 @@ static void stbte__layers(stbte_tilemap *tm, int x0, int y0, int w, int h)
n
=
stbte__text_width
(
"prop:"
)
+
2
;
stbte__draw_text
(
x0
,
y
+
2
,
"prop:"
,
w
,
STBTE__TEXTCOLOR
(
STBTE__cpanel
));
i
=
w
-
n
-
4
;
if
(
i
>
45
)
i
=
45
;
if
(
i
>
50
)
i
=
50
;
if
(
stbte__button
(
STBTE__clayer_button
,
propmodes
[
tm
->
propmode
],
x0
+
n
,
y
,
0
,
i
,
STBTE__ID
(
STBTE__layer
,
256
),
0
,
0
))
tm
->
propmode
=
(
tm
->
propmode
+
1
)
%
3
;
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录