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

Rename

parent 95993ffa
......@@ -4,7 +4,7 @@ error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'Data.class.php';
require_once 'model/Contents.class.php';
require_once 'model/Tabs.class.php';
$name = $_POST['name'];
$data = $_POST['data'];
......@@ -22,13 +22,13 @@ Data::saveXML($data, $name, $x, $y, $td);
echo '<br/>';
$levels = Data::loadXML($td);
$contents[] = array();
$tabs[] = array();
var_dump($levels);
foreach($levels as $level){
$myContent = new Contents();
$myContent = new tabs();
$myContent->importXML($level['content']);
$contents[] = $myContent;
$tabs[] = $myContent;
}
echo '<br/>';
......
<?php
class Contents
class Tabs
{
private static $tabwidth = 40;
private static $tabheight = 31;
private $mapwidth;
private $mapheight;
private $contentsRaw;
private $contents;
private $tabsRaw;
private $tabs;
public function __construct() {
$this->contentsRaw = null;
$this->tabsRaw = null;
$this->mapwidth = 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()),
......@@ -24,31 +24,31 @@ class Contents
public function importXML($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();
$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_y = (int) floor($i / (self::$tabwidth * self::$tabheight * $this->mapwidth));
$line[] = $contents[$i];
$line[] = $tabs[$i];
if($prev_y != $tab_y){
$this->contents[$tab_x][$tab_y] = $line;
$this->tabs[$tab_x][$tab_y] = $line;
$line = array();
}
}
}
public function setContents($contents) {
$this->contents = $contents;
public function settabs($tabs) {
$this->tabs = $tabs;
}
public function getContents() {
return $this->contents;
public function gettabs() {
return $this->tabs;
}
public function getTab($x, $y) {
......
<?php
include 'model/Contents.class.php';
include 'model/Tabs.class.php';
$xml = '<?xml version="1.0" ?>
<MapData version="2">
......@@ -429,6 +429,6 @@
</MapData>';
echo 'coucou';
$contents = new Contents();
$contents->importXML($xml);
$tabs = new Tabs();
$tabs->importXML($xml);
//echo 'coucou';
\ No newline at end of file
Markdown is supported
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