Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Normand Erwan
VVVVVV_level_merger
Commits
31df833e
Commit
31df833e
authored
Jun 01, 2015
by
Erwan Normand
Browse files
Rename
parent
95993ffa
Changes
3
Hide whitespace changes
Inline
Side-by-side
merge.php
View file @
31df833e
...
@@ -4,7 +4,7 @@ error_reporting(E_ALL);
...
@@ -4,7 +4,7 @@ error_reporting(E_ALL);
ini_set
(
'display_errors'
,
1
);
ini_set
(
'display_errors'
,
1
);
require_once
'Data.class.php'
;
require_once
'Data.class.php'
;
require_once
'model/
Content
s.class.php'
;
require_once
'model/
Tab
s.class.php'
;
$name
=
$_POST
[
'name'
];
$name
=
$_POST
[
'name'
];
$data
=
$_POST
[
'data'
];
$data
=
$_POST
[
'data'
];
...
@@ -22,13 +22,13 @@ Data::saveXML($data, $name, $x, $y, $td);
...
@@ -22,13 +22,13 @@ Data::saveXML($data, $name, $x, $y, $td);
echo
'<br/>'
;
echo
'<br/>'
;
$levels
=
Data
::
loadXML
(
$td
);
$levels
=
Data
::
loadXML
(
$td
);
$
content
s
[]
=
array
();
$
tab
s
[]
=
array
();
var_dump
(
$levels
);
var_dump
(
$levels
);
foreach
(
$levels
as
$level
){
foreach
(
$levels
as
$level
){
$myContent
=
new
Content
s
();
$myContent
=
new
tab
s
();
$myContent
->
importXML
(
$level
[
'content'
]);
$myContent
->
importXML
(
$level
[
'content'
]);
$
content
s
[]
=
$myContent
;
$
tab
s
[]
=
$myContent
;
}
}
echo
'<br/>'
;
echo
'<br/>'
;
...
...
model/
Content
s.class.php
→
model/
Tab
s.class.php
View file @
31df833e
<?php
<?php
class
Content
s
class
Tab
s
{
{
private
static
$tabwidth
=
40
;
private
static
$tabwidth
=
40
;
private
static
$tabheight
=
31
;
private
static
$tabheight
=
31
;
private
$mapwidth
;
private
$mapwidth
;
private
$mapheight
;
private
$mapheight
;
private
$
content
sRaw
;
private
$
tab
sRaw
;
private
$
content
s
;
private
$
tab
s
;
public
function
__construct
()
{
public
function
__construct
()
{
$this
->
content
sRaw
=
null
;
$this
->
tab
sRaw
=
null
;
$this
->
mapwidth
=
5
;
$this
->
mapwidth
=
5
;
$this
->
mapheight
=
5
;
$this
->
mapheight
=
5
;
$this
->
content
s
=
array
(
$this
->
tab
s
=
array
(
array
(
array
(),
array
(),
array
(),
array
(),
array
()),
array
(
array
(),
array
(),
array
(),
array
(),
array
()),
array
(
array
(),
array
(),
array
(),
array
(),
array
()),
array
(
array
(),
array
(),
array
(),
array
(),
array
()),
array
(
array
(),
array
(),
array
(),
array
(),
array
()),
array
(
array
(),
array
(),
array
(),
array
(),
array
()),
...
@@ -24,31 +24,31 @@ class Contents
...
@@ -24,31 +24,31 @@ class Contents
public
function
importXML
(
$string
)
{
public
function
importXML
(
$string
)
{
$xml
=
simplexml_load_string
(
$string
);
$xml
=
simplexml_load_string
(
$string
);
$this
->
content
sRaw
=
$xml
->
Data
->
content
s
->
__toString
();
$this
->
tab
sRaw
=
$xml
->
Data
->
tab
s
->
__toString
();
$
content
s
=
explode
(
','
,
$this
->
content
sRaw
);
$
tab
s
=
explode
(
','
,
$this
->
tab
sRaw
);
$line
=
array
();
$line
=
array
();
$prev_y
=
1
;
$prev_y
=
1
;
for
(
$i
=
0
;
$i
<
count
(
$
content
s
);
++
$i
){
for
(
$i
=
0
;
$i
<
count
(
$
tab
s
);
++
$i
){
$tab_x
=
(
int
)
floor
(
$i
/
self
::
$tabwidth
);
$tab_x
=
(
int
)
floor
(
$i
/
self
::
$tabwidth
);
$tab_y
=
(
int
)
floor
(
$i
/
(
self
::
$tabwidth
*
self
::
$tabheight
*
$this
->
mapwidth
));
$tab_y
=
(
int
)
floor
(
$i
/
(
self
::
$tabwidth
*
self
::
$tabheight
*
$this
->
mapwidth
));
$line
[]
=
$
content
s
[
$i
];
$line
[]
=
$
tab
s
[
$i
];
if
(
$prev_y
!=
$tab_y
){
if
(
$prev_y
!=
$tab_y
){
$this
->
content
s
[
$tab_x
][
$tab_y
]
=
$line
;
$this
->
tab
s
[
$tab_x
][
$tab_y
]
=
$line
;
$line
=
array
();
$line
=
array
();
}
}
}
}
}
}
public
function
set
Contents
(
$content
s
)
{
public
function
set
tabs
(
$tab
s
)
{
$this
->
contents
=
$content
s
;
$this
->
tabs
=
$tab
s
;
}
}
public
function
get
Content
s
()
{
public
function
get
tab
s
()
{
return
$this
->
content
s
;
return
$this
->
tab
s
;
}
}
public
function
getTab
(
$x
,
$y
)
{
public
function
getTab
(
$x
,
$y
)
{
...
...
test.php
View file @
31df833e
<?php
<?php
include
'model/
Content
s.class.php'
;
include
'model/
Tab
s.class.php'
;
$xml
=
'<?xml version="1.0" ?>
$xml
=
'<?xml version="1.0" ?>
<MapData version="2">
<MapData version="2">
...
@@ -429,6 +429,6 @@
...
@@ -429,6 +429,6 @@
</MapData>'
;
</MapData>'
;
echo
'coucou'
;
echo
'coucou'
;
$
content
s
=
new
Content
s
();
$
tab
s
=
new
Tab
s
();
$
content
s
->
importXML
(
$xml
);
$
tab
s
->
importXML
(
$xml
);
//echo 'coucou';
//echo 'coucou';
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment