Skip to content

Commit

Permalink
header menu - done
Browse files Browse the repository at this point in the history
and resource panel - just display static values
  • Loading branch information
Spamercz committed Jan 29, 2016
1 parent 020e7c7 commit afd4f10
Show file tree
Hide file tree
Showing 32 changed files with 596 additions and 316 deletions.
7 changes: 6 additions & 1 deletion App/Config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,9 @@ services:
- App\FrontModule\Model\OData\ODataModel
- App\FrontModule\Model\OData\OasisService
- App\FrontModule\Model\User\LoginService
- App\GameModule\Model\Online\OnlineModel
- App\GameModule\Model\Online\OnlineModel
- App\GameModule\Controls\Header\IHeaderControl
- App\GameModule\Model\MData\MDataModel
- App\GameModule\Model\NData\NDataModel
- App\FrontModule\Model\User\UserService
- App\GameModule\Controls\Resource\IResourceControl
33 changes: 33 additions & 0 deletions App/FrontModule/Model/User/UserService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\FrontModule\Model\User;

use App;
use Nette;

class UserService
{
/**
* @var UserModel
*/
private $userModel;


public function __construct(
UserModel $userModel
) {
$this->userModel = $userModel;
}


public function hasPlus($uid)
{
/** @var \stdClass $user */
$user = $this->userModel->get($uid);
if ($user->plus > time()) {
return TRUE;
} else {
return FALSE;
}
}
}
76 changes: 76 additions & 0 deletions App/GameModule/Controls/Header/HeaderControl.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<div id="header">
<div id="mtop">
<a href="{plink ':Game:OuterVillage:default'}" id="n1" accesskey="1"><img src="{$baseUrl}/img/x.gif" title="Village overview" alt="Village overview" /></a>
<a href="{plink ':Game:InnerVillage:default'}" id="n2" accesskey="2"><img src="{$baseUrl}/img/x.gif" title="Village centre" alt="Village centre" /></a>
<a href="{plink ':Game:Map:default'}" id="n3" accesskey="3"><img src="{$baseUrl}/img/x.gif" title="Map" alt="Map" /></a>
<a href="{plink ':Game:Statistics:default'}" id="n4" accesskey="4"><img src="{$baseUrl}/img/x.gif" title="Statistics" alt="Statistics" /></a>
<div id="n5" n:class="
$unread && ! $report ? i2,
! $unread && $report ? i3,
$unread && $report ? i1,
! $unread && ! $report ? i4
">
<a href="{plink ':Game:Reports:default'}" accesskey="5"><img src="{$baseUrl}/img/x.gif" class="l" title="Reports" alt="Reports"/></a>
<a href="{plink ':Game:Messages:default'}" accesskey="6"><img src="{$baseUrl}/img/x.gif" class="r" title="Messages" alt="Messages" /></a>
</div>

<a href="{plink ':Game:Plus:default'}" id="plus">
<span class="plus_text">
<span class="plus_g">P</span>
<span class="plus_o">l</span>
<span class="plus_g">u</span>
<span class="plus_o">s</span>
</span>
<img src="{$baseUrl}/img/x.gif" id="btn_plus" n:class="$plusActive ? active, ! $plusActive ? inactive"
title="Plus menu" alt="Plus menu" />
</a>

<style>
.day_image {
background-image: url("../gpack/travian_default/img/l/day.gif");
width: 18px;
height:18px;
}
.night_image {
background-image: url("../gpack/travian_default/img/l/night.gif");
width: 18px;
height:18px;
}
#container {
width: 30px;
height: 60px;
position: relative;
}
#wrapper > #container {
display: table;
position: static;
}
#container div {
position: absolute;
top: 50%;
}
#container div div {
position: relative;
top: -50%;
}
#container > div {
display: table-cell;
vertical-align: middle;
position: static;
}
</style>
{var hour = date('Hi')}
<div id="wrapper">
<div id="container">
<div>
<div>
<p>
<img src="{$baseUrl}/img/x.gif" style="display: block; margin: 0 auto; vertical-align:middle;" n:class="$hour > 1750 || $hour < 500 ? night_image : day_image" />
</p>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
43 changes: 43 additions & 0 deletions App/GameModule/Controls/Header/HeaderControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace App\GameModule\Controls\Header;

use Nette;
use App;

class HeaderControl extends Nette\Application\UI\Control
{
/**
* @var App\GameModule\Model\MData\MDataModel
*/
private $MDataModel;
/**
* @var App\GameModule\Model\NData\NDataModel
*/
private $NDataModel;
/**
* @var App\FrontModule\Model\User\UserService
*/
private $userService;


public function __construct(
App\GameModule\Model\MData\MDataModel $MDataModel,
App\GameModule\Model\NData\NDataModel $NDataModel,
App\FrontModule\Model\User\UserService $userService
) {
$this->MDataModel = $MDataModel;
$this->NDataModel = $NDataModel;
$this->userService = $userService;
}


public function render()
{
$this->template->unread = $this->MDataModel->countUnread($this->presenter->getUser()->getId()) ? TRUE : FALSE;
$this->template->report = $this->NDataModel->countUnread($this->presenter->getUser()->getId()) ? TRUE : FALSE;
$this->template->plusActive = $this->userService->hasPlus($this->presenter->getUser()->getId());
$this->template->setFile(__DIR__ . '/HeaderControl.latte');
$this->template->render();
}
}
10 changes: 10 additions & 0 deletions App/GameModule/Controls/Header/IHeaderControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App\GameModule\Controls\Header;


interface IHeaderControl
{
/** @return HeaderControl */
function create();
}
16 changes: 16 additions & 0 deletions App/GameModule/Controls/Header/THeaderControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\GameModule\Controls\Header;


trait THeaderControl
{
/** @var IHeaderControl @inject */
public $headerFactory;


protected function createComponentHeader()
{
return $this->headerFactory->create();
}
}
12 changes: 12 additions & 0 deletions App/GameModule/Controls/Resource/IResourceControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace App\GameModule\Controls\Resource;

use Nette;
use App;

interface IResourceControl
{
/** @return ResourceControl */
public function create();
}
53 changes: 53 additions & 0 deletions App/GameModule/Controls/Resource/ResourceControl.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<div id="res">
<div id="resWrap">
<table cellpadding="1" cellspacing="1">
<tr>
<td>
<img src="{$baseUrl}/img/x.gif" class="r1" alt="Lumber" title="Lumber" />
</td>
<td id="l4" title="Wood">
{$actualWood} / {$store}
</td>
<td>
<img src="{$baseUrl}/img/x.gif" class="r2" alt="Clay" title="Clay" />
</td>
<td id="l3" title="Clay">
{$actualClay} / {$store}
</td>
<td>
<img src="{$baseUrl}/img/x.gif" class="r3" alt="Iron" title="Iron" />
</td>
<td id="l2" title="Iron">
{$actualIron} / {$store}
</td>
<td>
<img src="{$baseUrl}/img/x.gif" class="r4" alt="Crop" title="Crop" />
</td>


<td id="l1" title="Crop" n:if="$actualCrop > 0">
{$actualCrop} / {$granary}
</td>
<td>
<img src="{$baseUrl}/img/x.gif" class="r5" alt="Crop consumption" title="Crop consumption" /></td>
<td>
{$upkeep} / {$cropProduction}
</td>
</tr>
</table>
<table cellpadding="1" cellspacing="1">
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td></td>
<td>
<font color="#B3B3B3" n:tag-if="$gold < 2">
<img src="{$baseUrl}/gpack/travian_default/img/a/gold.gif" alt="Remaining gold" title="You currently have: {$gold} gold"/> {$gold} <span><span>G</span><span>o</span><span>l</span><span>d</span></span>
</font>
</td>
</tr>
</table>
</div>
</div>
26 changes: 26 additions & 0 deletions App/GameModule/Controls/Resource/ResourceControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\GameModule\Controls\Resource;

use Nette;
use App;

class ResourceControl extends Nette\Application\UI\Control
{
public function render()
{
$this->template->actualWood = 750;
$this->template->actualClay = 750;
$this->template->actualIron = 750;
$this->template->actualCrop = 750;
$this->template->store = 800;
$this->template->granary = 800;
$this->template->upkeep = 2;
$this->template->cropProduction = 15;
$this->template->gold = 40;


$this->template->setFile(__DIR__ . '/ResourceControl.latte');
$this->template->render();
}
}
18 changes: 18 additions & 0 deletions App/GameModule/Controls/Resource/TResourceControl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\GameModule\Controls\Resource;

use Nette;
use App;

trait TResourceControl
{
/** @var IResourceControl @inject */
public $resourceFactory;


protected function createComponentResource()
{
return $this->resourceFactory->create();
}
}
37 changes: 37 additions & 0 deletions App/GameModule/Model/MData/MDataModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\GameModule\Model\MData;

use App;

class MDataModel extends App\Model\BaseModel
{
protected $table = 'mdata';


/**
* @param int $uid
* @return array
*/
public function getUnread($uid)
{
return $this->database->select('*')->from($this->table)
->where('viewed != 1')
->where('send = 1')
->where('target = %i', $uid)
->fetchAll();
}

/**
* @param int $uid
* @return array
*/
public function countUnread($uid)
{
return $this->database->select('count(id)')->from($this->table)
->where('viewed != 1')
->where('send = 1')
->where('target = %i', $uid)
->fetchSingle();
}
}
35 changes: 35 additions & 0 deletions App/GameModule/Model/NData/NDataModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\GameModule\Model\NData;

use App;

class NDataModel extends App\Model\BaseModel
{
protected $table = 'ndata';


/**
* @param int $uid
* @return array
*/
public function getUnread($uid)
{
return $this->database->select('*')->from($this->table)
->where('viewed != 1')
->where('uid = %i', $uid)
->fetchAll();
}

/**
* @param int $uid
* @return array
*/
public function countUnread($uid)
{
return $this->database->select('count(id)')->from($this->table)
->where('viewed != 1')
->where('uid = %i', $uid)
->fetchSingle();
}
}
Loading

0 comments on commit afd4f10

Please sign in to comment.