#1470 Achievement summary added; improved menu handling; Class scheme (UML) added;

This commit is contained in:
SirCotare 2012-05-28 21:09:44 +02:00
parent 938f2a9509
commit fe077f3e49
11 changed files with 254 additions and 40 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

View file

@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net -- http://www.phpmyadmin.net
-- --
-- Host: localhost -- Host: localhost
-- Erstellungszeit: 27. Mai 2012 um 21:06 -- Erstellungszeit: 28. Mai 2012 um 21:07
-- Server Version: 5.1.46 -- Server Version: 5.1.46
-- PHP-Version: 5.3.2 -- PHP-Version: 5.3.2
@ -51,11 +51,37 @@ INSERT INTO `ach_atom` (`atom_id`, `atom_objective`, `atom_mandatory`, `atom_rul
-- --
INSERT INTO `ach_category` (`ac_id`, `ac_parent`, `ac_order`, `ac_image`) VALUES INSERT INTO `ach_category` (`ac_id`, `ac_parent`, `ac_order`, `ac_image`) VALUES
(1, NULL, 0, ''), (1, NULL, 20, ''),
(2, NULL, 0, ''), (2, NULL, 40, ''),
(3, 1, 0, ''), (3, 1, 2000, ''),
(4, 1, 0, ''), (4, 1, 2000, ''),
(5, 1, 0, ''); (5, 1, 2000, ''),
(6, NULL, 70, ''),
(7, NULL, 30, ''),
(8, NULL, 50, ''),
(9, NULL, 10, ''),
(10, 1, 2000, ''),
(11, 1, 2010, ''),
(12, 8, 5000, ''),
(13, 8, 5000, ''),
(14, 8, 5000, ''),
(15, 8, 5000, ''),
(16, 6, 7010, ''),
(17, 6, 7020, ''),
(18, 6, 7200, ''),
(19, 7, 3010, ''),
(20, 7, 3010, ''),
(21, 7, 3020, ''),
(22, 7, 3020, ''),
(23, 7, 3020, ''),
(24, 7, 3030, ''),
(25, 7, 3040, ''),
(26, 7, 3020, ''),
(27, 6, 7100, ''),
(28, NULL, 60, ''),
(29, 28, 6010, ''),
(30, 28, 6020, ''),
(31, NULL, 80, '');
-- --
-- Daten für Tabelle `ach_category_lang` -- Daten für Tabelle `ach_category_lang`
@ -66,7 +92,33 @@ INSERT INTO `ach_category_lang` (`acl_category`, `acl_lang`, `acl_name`) VALUES
(2, 'en', 'Occupations'), (2, 'en', 'Occupations'),
(3, 'en', 'Aeden Aqueous'), (3, 'en', 'Aeden Aqueous'),
(4, 'en', 'Burning Desert'), (4, 'en', 'Burning Desert'),
(5, 'en', 'Witherings'); (5, 'en', 'Witherings'),
(6, 'en', 'The Saga of Ryzom'),
(7, 'en', 'Fame'),
(8, 'en', 'Skills'),
(9, 'en', 'General'),
(10, 'en', 'Verdant Heights'),
(11, 'en', 'Prime Roots'),
(12, 'en', 'Craft'),
(13, 'en', 'Fight'),
(14, 'en', 'Harvest'),
(15, 'en', 'Magic'),
(16, 'en', 'Episode I'),
(17, 'en', 'Episode II'),
(18, 'en', 'Legacy'),
(19, 'en', 'Civilizations'),
(20, 'en', 'Higher Powers'),
(21, 'en', 'Aeden Aqueous'),
(22, 'en', 'Burning Desert'),
(23, 'en', 'Verdant Heights'),
(24, 'en', 'The Nexus'),
(25, 'en', 'Prime Roots'),
(26, 'en', 'Witherings'),
(27, 'en', 'Encyclopedia'),
(28, 'en', 'PvP'),
(29, 'en', 'Civilizations'),
(30, 'en', 'Higher Powers'),
(31, 'en', 'Ryzom Ring');
-- --
-- Daten für Tabelle `ach_objective` -- Daten für Tabelle `ach_objective`

View file

@ -7,6 +7,14 @@
$this->open = $open; $this->open = $open;
$tmp = array();
$tmp['ac_id'] = 0;
$tmp['ac_parent'] = null;
$tmp['acl_name'] = get_translation('ach_summary',$lang);
$tmp['ac_image'] = "";
$tmp['ac_order'] = -1;
$this->nodes[] = new AchMenuNode($tmp,$open,$lang);
$res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent IS NULL ORDER by ac_order ASC, acl_name ASC"); $res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent IS NULL ORDER by ac_order ASC, acl_name ASC");
$sz = sizeof($res); $sz = sizeof($res);
@ -15,9 +23,19 @@
} }
} }
function getCat() { function getOpen() {
return $this->open; return $this->open;
} }
function getOpenCat() {
foreach($this->nodes as $elem) {
$res = $elem->hasOpenCat();
if($res != 0) {
return $res;
}
}
return 0;
}
} }
class AchMenuNode extends RenderNodeIterator { class AchMenuNode extends RenderNodeIterator {
@ -36,7 +54,7 @@
$this->name = $data['acl_name']; $this->name = $data['acl_name'];
$this->image = $data['ac_image']; $this->image = $data['ac_image'];
$this->order = $data['ac_order']; $this->order = $data['ac_order'];
$this->open = ($open==$data['ac_id']); $this->open = ($this->id == $open);
$res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent='".$this->id."' ORDER by ac_order ASC, acl_name ASC"); $res = $db->sqlQuery("SELECT * FROM ach_category LEFT JOIN (ach_category_lang) ON (acl_lang='".$lang."' AND acl_category=ac_id) WHERE ac_parent='".$this->id."' ORDER by ac_order ASC, acl_name ASC");
@ -58,6 +76,20 @@
return $this->parent; return $this->parent;
} }
function hasOpenCat() {
if($this->open) {
return $this->id;
}
foreach($this->nodes as $elem) {
$res = $elem->hasOpenCat();
if($res != 0) {
return $res;
}
}
return 0;
}
function isOpen() { function isOpen() {
return $this->open; return $this->open;
} }

View file

@ -1,20 +1,69 @@
<?php <?php
class AchSummary extends AchList { class AchSummary extends AchList {
private $menu;
private $stats;
function AchSummary($size = 10,$lang = 'en') { function AchSummary(&$menu,$user,$size = 10,$lang = 'en') {
global $db; global $db;
$res = $db->sqlQuery("SELECT * FROM ach_achievement LEFT JOIN (ach_achievement_lang) ON (aal_lang='".$lang."' AND aal_achievement=aa_id) WHERE aa_parent IS NULL"); $this->menu = $menu;
#MISSING: or parent is done
#MISSING: player's status on achievement //read all recent perks of user
//make distinct achievement list
$res = $db->sqlQuery("SELECT DISTINCT aa_id,ach.*,(SELECT aal_name FROM ach_achievement_lang WHERE aal_lang='".$lang."' AND aal_achievement=ach.aa_id) as aal_name FROM ach_achievement as ach,ach_perk,ach_player_perk WHERE ap_achievement=aa_id AND app_player='".$user."' AND app_perk=ap_id ORDER by app_date DESC LIMIT 0,".($size-1));
$sz = sizeof($res); $sz = sizeof($res);
for($i=0;$i<$sz;$i++) { for($i=0;$i<$sz;$i++) {
$tmp = new AchAchievement($res[$i],$lang); $tmp = new AchAchievement($res[$i],$lang,$user);
if($tmp->hasDone()) {
$this->child_done[] = sizeof($this->nodes); $this->child_done[] = sizeof($this->nodes);
$this->nodes[] = $tmp; $this->nodes[] = $tmp;
} }
} }
function getSummary($lang,$user) {
if(!is_array($this->stats)) { // only load if needed
//now we have to find the # of perks for each main menu entry
//and also sum up how many have been completed
$this->stats = array(); // [][name,done,total]
$tmp = $this->menu->getChildren();
foreach($tmp as $elem) {
if($elem->getID() == 0) {
continue; // skip summary page
}
$res = $this->sumStats($elem,$user);
$this->stats[] = array($elem->getName(),$res[0],$res[1]);
}
}
return $this->stats;
}
private function sumStats(&$node,$user) {
global $db;
$done = 0;
$total = 0;
//read for current ID
//sum
$res = $db->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement,ach_player_perk WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id AND app_player='".$user."' AND app_perk=ap_id");
$done += $res[0]["anz"];
$res = $db->sqlQuery("SELECT count(ap_id) as anz FROM ach_perk,ach_achievement WHERE aa_category='".$node->getID()."' AND ap_achievement=aa_id");
$total += $res[0]["anz"];
$tmp = $node->getChildren();
foreach($tmp as $elem) {
$res = $this->sumStats($elem,$user);
$done += $res[0];
$total += $res[1];
}
return array($done,$total);
} }
} }
?> ?>

View file

@ -25,17 +25,21 @@
$sz = $menu->getSize(); $sz = $menu->getSize();
for($i=0;$i<$sz;$i++) { for($i=0;$i<$sz;$i++) {
$curr = $menu->getChild($i); $curr = $menu->getChild($i);
$html .= "<span class='ach_mspan'><a href=''><table class='ach_menu'> $html .= "<span class='ach_mspan'><a href='?lang=en&cat=".$curr->getID()."'><table class='ach_menu'>
<tr> <tr>";
<td><img src='pic/menu/test.png' /></td> if($sub == 0) {
<td style='font-size:".(20-$sub)."px;font-weight:bold;"; $html .= "<td><img src='pic/menu/test.png' /></td>";
}
$html .= "<td style='font-size:".(20-$sub)."px;font-weight:bold;";
if($curr->isOpen()) { if($curr->isOpen()) {
$html .= "color:orange;"; $html .= "color:orange;";
} }
$html .= "'>".$curr->getName()."</td> $html .= "'>".$curr->getName()."</td>
</tr> </tr>
</table></a></span> </table></a></span>";
<div style='display:block;margin-left:25px;'>".ach_render_menu($curr,($sub+4))."</div>"; if($curr->hasOpenCat() != 0) {
$html .= "<div style='display:block;margin-left:25px;'>".ach_render_menu($curr,($sub+4))."</div>";
}
} }
return $html; return $html;
@ -256,15 +260,18 @@
else { else {
$col = "#999999"; $col = "#999999";
} }
$html .= "<div style='color:".$col.";display:block;'>".$obj->getName()."</span><div />"; $html .= "<div style='color:".$col.";display:block;'>".$obj->getName()."</div>";
$val = $obj->getValue(); $html .= ach_render_progressbar($obj->getProgress(),$obj->getValue(),350);
$prog = $obj->getProgress();
$width = 350; return $html;
}
function ach_render_progressbar($prog,$val,$width) {
$val = max(1,$val);
$left = floor($width*(100*($prog/$val))/100); $left = floor($width*(100*($prog/$val))/100);
$html .= " $html = "
<table width='".$width."px' cellspacing='0' cellpadding='0' style='border:1px solid #FFFFFF;color:#000000;'> <table width='".$width."px' cellspacing='0' cellpadding='0' style='border:1px solid #FFFFFF;color:#000000;'>
<tr> <tr>
<td bgcolor='#66CC00' width='".$left."px' align='right'>"; <td bgcolor='#66CC00' width='".$left."px' align='right'>";
@ -282,4 +289,48 @@
return $html; return $html;
} }
function ach_render_summary_header($lang) {
return "<div style='display:block;font-weight:bold;font-size:30px;color:#FFFFFF;text-align:center;margin-bottom:10px;'>".get_translation('ach_summary_header',$lang)."</div>";
}
function ach_render_summary_footer($lang,&$summary,$user) {
$nodes = $summary->getSummary($lang,$user);
$html = "";
$sum_done = 0;
$sum_total = 0;
$i = 0;
foreach($nodes as $elem) {
if(($i%3) == 0) {
$html .= "<tr>";
}
$html .= "<td width='50%' align='center'>".$elem[0]."<br>".ach_render_progressbar($elem[1],$elem[2],200)."</td>";
$sum_done += $elem[1];
$sum_total += $elem[2];
if(($i%3) == 2) {
$html .= "</tr>";
}
$i++;
}
if(($i%3) == 2) {
$html .= "</tr>";
}
$html = "<p />
<div style='display:block;font-weight:bold;font-size:30px;color:#FFFFFF;text-align:center;margin-bottom:10px;'>".get_translation('ach_summary_stats',$lang)."</div>
<table>
<tr>
<td colspan='3' align='center'>".get_translation('ach_summary_stats_total',$lang)."<br>".ach_render_progressbar($sum_done,$sum_total,450)."<br></td>
</tr>
".$html."
</table>";
return $html;
}
?> ?>

View file

@ -50,10 +50,10 @@ $c = _t('access', $num_access['num_access']).'<br/>';*/
$c = "<center><table> $c = "<center><table>
<tr> <tr>
<td valign='top'><div style='width:220px;font-weight:bold;font-size:14px;'>"; <td valign='top'><div style='width:230px;font-weight:bold;font-size:14px;'>";
$_REQUEST['mid'] = 1; #$_REQUEST['mid'] = 1;
$menu = new AchMenu($_REQUEST['mid'],$user['lang']); $menu = new AchMenu($_REQUEST['cat'],$user['lang']);
$c .= ach_render_menu($menu); $c .= ach_render_menu($menu);
@ -64,14 +64,20 @@ $c .= "</div></td>
$c .= ach_render_box_done("Bejeweled"); $c .= ach_render_box_done("Bejeweled");
}*/ }*/
#if($menu->isSelected()) { $open = $menu->getOpenCat();
$cat = new AchCategory($menu->getCat(),1,$user['lang']);
#} if($open != 0) {
#else { $cat = new AchCategory($open,1,$user['lang']);
# $cat = new AchSummary(12,$user['lang']); }
#} else {
$cat = new AchSummary($menu,1,8,$user['lang']);
$c .= ach_render_summary_header($user['lang']);
}
$c .= ach_render_category($cat); $c .= ach_render_category($cat);
if($open == 0) {
$c .= ach_render_summary_footer($user['lang'],$cat,1);
}
$c .= "</td> $c .= "</td>
</tr> </tr>

View file

@ -1,13 +1,37 @@
<?php // %2011-09-28T08:12:16+02:00 <?php // %2011-09-28T08:12:16+02:00
$__texts = array ( $__texts = array (
'access' => 'ach_summary' =>
array ( array (
'en' => 'User access this page %s times', 'en' => 'Summary',
'fr' => 'L\'utilisateur a accede a cette page %s fois', 'fr' => '',
'de' => '',
'ru' => '',
),
'ach_summary_header' =>
array (
'en' => 'Recent Achievements',
'fr' => '',
'de' => '',
'ru' => '',
),
'ach_summary_stats' =>
array (
'en' => 'Statistics',
'fr' => '',
'de' => '',
'ru' => '',
),
'ach_summary_stats_total' =>
array (
'en' => 'Total',
'fr' => '',
'de' => '', 'de' => '',
'ru' => '', 'ru' => '',
), ),
); );
if(isset($ryzom_texts)) if(isset($ryzom_texts))
$ryzom_texts = array_merge ($__texts, $ryzom_texts); $ryzom_texts = array_merge ($__texts, $ryzom_texts);
else else