Commit 31df833e authored by Erwan Normand's avatar Erwan Normand
Browse files

Rename

parent 95993ffa
...@@ -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/Contents.class.php'; require_once 'model/Tabs.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);
$contents[] = array(); $tabs[] = array();
var_dump($levels); var_dump($levels);
foreach($levels as $level){ foreach($levels as $level){
$myContent = new Contents(); $myContent = new tabs();
$myContent->importXML($level['content']); $myContent->importXML($level['content']);
$contents[] = $myContent; $tabs[] = $myContent;
} }
echo '<br/>'; echo '<br/>';
......
<?php <?php
class Contents class Tabs
{ {
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 $contentsRaw; private $tabsRaw;
private $contents; private $tabs;
public function __construct() { public function __construct() {
$this->contentsRaw = null; $this->tabsRaw = null;
$this->mapwidth = 5; $this->mapwidth = 5;
$this->mapheight = 5; $this->mapheight = 5;
$this->contents = array( $this->tabs = 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->contentsRaw = $xml->Data->contents->__toString(); $this->tabsRaw = $xml->Data->tabs->__toString();
$contents = explode(',', $this->contentsRaw); $tabs = explode(',', $this->tabsRaw);
$line = array(); $line = array();
$prev_y = 1; $prev_y = 1;
for($i=0; $i<count($contents); ++$i){ for($i=0; $i<count($tabs); ++$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[] = $contents[$i]; $line[] = $tabs[$i];
if($prev_y != $tab_y){ if($prev_y != $tab_y){
$this->contents[$tab_x][$tab_y] = $line; $this->tabs[$tab_x][$tab_y] = $line;
$line = array(); $line = array();
} }
} }
} }
public function setContents($contents) { public function settabs($tabs) {
$this->contents = $contents; $this->tabs = $tabs;
} }
public function getContents() { public function gettabs() {
return $this->contents; return $this->tabs;
} }
public function getTab($x, $y) { public function getTab($x, $y) {
......
<?php <?php
include 'model/Contents.class.php'; include 'model/Tabs.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';
$contents = new Contents(); $tabs = new Tabs();
$contents->importXML($xml); $tabs->importXML($xml);
//echo 'coucou'; //echo 'coucou';
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment