Ported the menu.

This commit is contained in:
Relintai 2021-10-30 23:33:37 +02:00
parent 96d8c1fcf2
commit 5881f4bbf0
2 changed files with 164 additions and 97 deletions

View File

@ -20,6 +20,25 @@
void MourneApplication::index(Object *instance, Request *request) { void MourneApplication::index(Object *instance, Request *request) {
add_menu(request, MENUENTRY_NEWS); add_menu(request, MENUENTRY_NEWS);
/*
<?php if (isset($hero)): ?>
<link rel="stylesheet" type="text/css" href="<?=base_url('css/hero.css'); ?>">
<?php endif; ?>
<?php if ($userlevel > 2): ?>
<link rel="stylesheet" type="text/css" href="<?=base_url('css/admin.css'); ?>">
<?php endif; ?>
<?php if ($page == 'mail'): ?>
<link rel="stylesheet" type="text/css" href="<?=base_url('css/mail.css'); ?>">
<?php endif; ?>
<?php if ($resources): ?>
<script src="<?=base_url('js/resource.js'); ?>"></script>
<?php endif; ?>
*/
//dynamic_cast<ListPage *>(instance)->index(request); //dynamic_cast<ListPage *>(instance)->index(request);
request->body += "test"; request->body += "test";
request->compile_and_send_body(); request->compile_and_send_body();
@ -36,7 +55,144 @@ void MourneApplication::session_middleware_func(Object *instance, Request *reque
void MourneApplication::add_menu(Request *request, const MenuEntries index) { void MourneApplication::add_menu(Request *request, const MenuEntries index) {
request->head += menu_head; request->head += menu_head;
request->body += menu_strings[index];
HTMLBuilder b;
HTMLTag *t;
/*
<?php if ($weather): ?>
<div class="menu_base <?=$weather['css']; ?>">
<?php else: ?>
<div class="menu_base">
<?php endif; ?>
*/
b.div()->cls("menu_base");
{
b.div()->cls("left");
{
b.div()->cls("menu_news");
{
b.a()->href("/news/index");
b.w("News");
b.ca();
}
b.cdiv();
b.div()->cls("menu_mail");
{
b.a()->href("/mail/inbox");
b.w("Mails");
//if ($newmail) echo '!';
b.ca();
}
b.cdiv();
b.div()->cls("menu_hero");
{
b.a()->href("/hero/selected");
b.w("Hero");
b.ca();
}
b.cdiv();
b.div()->cls("menu_village");
{
b.a()->href("/village/selected");
b.w("Village"); //villagename
b.ca();
}
b.cdiv();
b.div()->cls("menu_sel_village");
{
b.a()->href("/village/select");
b.w("v");
b.ca();
}
b.cdiv();
/*
<?php if ($alliancename): ?>
<div class="menu_alliance">
<a href="<?=site_url($menu_alliance); ?>">[<?=$alliancename; ?>]</a>
</div>
<?php endif; ?>
*/
/*
<?php if ($weather): ?>
<div class="weather">
<abbr title="<?=$weather['description']; ?>"><?=$weather['name']; ?></abbr>
</div>
<?php endif; ?>
*/
}
b.cdiv();
b.div()->cls("right");
{
/*
<?php if ($userlevel > 4): ?>
<div class="menu_gm">
<a href="<?=site_url($link_gm); ?>">GM</a>
</div>
<?php endif; ?>
*/
/*
<?php if ($userlevel > 5): //dev+?>
<div class="menu_admin">
<a href="<?=site_url($link_admin); ?>">Admin</a>
</div>
<?php endif; ?>
*/
b.div()->cls("menu_alliance_menu");
{
b.a()->href("/alliance/alliance_menu");
b.w("Alliances");
b.ca();
}
b.cdiv();
b.div()->cls("menu_forum");
{
b.a()->href("/forum/index");
b.w("Forum");
b.ca();
}
b.cdiv();
b.div()->cls("menu_settings");
{
b.a()->href("/user/settings");
b.w("Settings");
b.ca();
}
b.cdiv();
b.div()->cls("menu_logout");
{
b.a()->href("/user/logout");
b.w("Logout");
b.ca();
}
b.cdiv();
}
b.cdiv();
b.div()->cls("nofloat");
b.cdiv();
}
b.cdiv();
b.div()->cls("main");
b.write_tag();
request->body += b.result;
request->footer = footer; request->footer = footer;
} }
@ -73,97 +229,17 @@ void MourneApplication::migrate() {
} }
void MourneApplication::compile_menu() { void MourneApplication::compile_menu() {
for (int i = 0; i < MENUENTRY_MAX; ++i) {
HTMLBuilder b;
HTMLTag *t;
b.div()->cls("content");
{
b.ul()->cls("menu");
{
b.li();
t = b.a()->href("/");
if (i == MENUENTRY_NEWS) {
t->cls("menu_active");
}
b.w("TSITE");
b.ca();
b.cli();
b.li();
t = b.a()->href("/village/selected");
if (i == MENUENTRY_VILLAGE) {
t->cls("menu_active");
}
b.w("Projects");
b.ca();
b.cli();
b.li();
{
t = b.a()->href("/village/select");
if (i == MENUENTRY_SELECT_VILLAGE) {
t->cls("menu_active");
}
b.w("Classes");
b.ca();
}
b.cli();
b.li();
{
t = b.a()->href("/user/login");
b.w("Login");
b.ca();
}
b.cli();
b.li();
{
t = b.a()->href("/user/register");
b.w("Register");
b.ca();
}
b.cli();
b.li();
{
t = b.a()->href("/user/settings");
b.w("Profile");
b.ca();
}
b.cli();
b.li();
{
t = b.a()->href("/user/logout");
b.w("Logout");
b.ca();
}
b.cli();
}
b.cul();
}
b.div()->cls("inner_content");
b.write_tag();
menu_strings.push_back(b.result);
}
HTMLBuilder bh; HTMLBuilder bh;
bh.meta()->charset_utf_8(); bh.meta()->charset_utf_8();
bh.meta()->name("description")->content("RPG browsergame");
bh.meta()->name("keywords")->content("RPG,browsergame,Mourne,game,play");
bh.title();
bh.w("Mourne");
bh.ctitle();
bh.link()->rel_stylesheet()->href("/css/main.css"); bh.link()->rel_stylesheet()->href("/css/base.css");
bh.link()->rel_stylesheet()->href("/css/menu.css");
bh.write_tag(); bh.write_tag();
menu_head = bh.result; menu_head = bh.result;
@ -172,15 +248,8 @@ void MourneApplication::compile_menu() {
bf.cdiv(); bf.cdiv();
bf.footer(); bf.footer();
bf.w("Powered by ");
bf.a()->href("https://github.com/Relintai/rcpp_cms");
bf.w("rcpp cms");
bf.ca();
bf.w(".");
bf.cfooter(); bf.cfooter();
bf.cdiv();
footer = bf.result; footer = bf.result;
} }
@ -193,6 +262,5 @@ MourneApplication::MourneApplication() :
MourneApplication::~MourneApplication() { MourneApplication::~MourneApplication() {
} }
std::vector<std::string> MourneApplication::menu_strings;
std::string MourneApplication::menu_head = ""; std::string MourneApplication::menu_head = "";
std::string MourneApplication::footer = ""; std::string MourneApplication::footer = "";

View File

@ -48,7 +48,6 @@ public:
MourneApplication(); MourneApplication();
~MourneApplication(); ~MourneApplication();
static std::vector<std::string> menu_strings;
static std::string menu_head; static std::string menu_head;
static std::string footer; static std::string footer;
}; };