source: branches/work_320/doc/menus/DocCharacterMenu.cpp @ 652

Revision 652, 2.2 KB checked in by jls17, 4 years ago (diff)
  • extracted method which does handle a single ARCharMenuList
Line 
1//Copyright (C) 2014 John Luthgers | jls17
2//
3//This file is part of ARInside.
4//
5//    ARInside is free software: you can redistribute it and/or modify
6//    it under the terms of the GNU General Public License as published by
7//    the Free Software Foundation, version 2 of the License.
8//
9//    ARInside is distributed in the hope that it will be useful,
10//    but WITHOUT ANY WARRANTY; without even the implied warranty of
11//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12//    GNU General Public License for more details.
13//
14//    You should have received a copy of the GNU General Public License
15//    along with ARInside.  If not, see <http://www.gnu.org/licenses/>.
16
17#include "stdafx.h"
18#include "DocCharacterMenu.h"
19#include "../../core/ARCharMenu.h"
20#include "../../core/AREnum.h"
21#include "../../output/Table.h"
22
23using namespace OUTPUT;
24
25CDocCharacterMenu::CDocCharacterMenu(CTable &table, CARCharMenu &menuObj)
26: outputTable(table), menu(menuObj), itemTable(new OUTPUT::CTable("menuItems", "TblObjectList"))
27{
28        itemTable->AddColumn(20, "Type");       
29        itemTable->AddColumn(40, "Label");
30        itemTable->AddColumn(40, "Value");
31}
32
33void CDocCharacterMenu::Documentation()
34{
35        try
36        {
37                const ARCharMenuStruct &menuDef = menu.GetDefinition();
38                assert(menuDef.menuType == AR_CHAR_MENU_LIST);
39
40                CreateItemList(menuDef.u.menuList);
41               
42                CTableRow row;
43                row.AddCell("Menu Definition");
44                row.AddCell(itemTable->ToXHtml());
45                outputTable.AddRow(row);
46        }
47        catch(exception& e)
48        {
49                cout << "EXCEPTION Menu details doc of '" << this->menu.GetName() << "': " << e.what() << endl;
50        }
51}
52
53void CDocCharacterMenu::CreateItemList(const ARCharMenuList &menu)
54{
55        for(unsigned int i=0; i< menu.numItems; i++)
56        {
57                CTableRow row("cssStdRow");             
58                CTableCell cellItemType(CAREnum::MenuItemType(menu.charMenuList[i].menuType), "");                             
59                CTableCell cellItemLabel(menu.charMenuList[i].menuLabel, "");
60
61                string mValue = "";
62                if(menu.charMenuList[i].menuType == AR_MENU_TYPE_VALUE)
63                        mValue = menu.charMenuList[i]   .u.menuValue;
64                CTableCell cellItemValue(mValue, "");
65
66                row.AddCell(cellItemType);
67                row.AddCell(cellItemLabel);
68                row.AddCell(cellItemValue);
69                itemTable->AddRow(row);         
70        }
71}
Note: See TracBrowser for help on using the repository browser.