Fix identification of generated recent menu items. Add codeblocks notes.

master
poikilos 2021-03-22 19:34:34 -04:00
parent e9d05030b6
commit 6d3496fb37
5 changed files with 89 additions and 24 deletions

View File

@ -335,7 +335,7 @@ bool UserInterface::handleMenuItemPressed(const SEvent::SGUIEvent* ge)
IGUIContextMenu* menu = static_cast<IGUIContextMenu*>(ge->Caller);
s32 callerID = ge->Caller->getID();
s32 selected = menu->getSelectedItem();
s32 id = menu->getItemCommandId(static_cast<u32>(selected));
s32 commandID = menu->getItemCommandId(static_cast<u32>(selected));
switch (callerID) {
case UIE_RECENTMENU:
// if ((ge->Caller->getID() >= this->m_file_recent_first_idx)
@ -343,12 +343,18 @@ bool UserInterface::handleMenuItemPressed(const SEvent::SGUIEvent* ge)
// NOTE: ge->Caller->getID() is probably UIE_RECENTMENU now, but that is not to be used directly!
cerr << "selected " << selected << std::endl;
if (std::find(this->recentIndices.begin(), this->recentIndices.end(), selected) != this->recentIndices.end()) {
cerr << "Recent item id: " << callerID << endl;
// cerr << "parent callerID: " << callerID << endl;
// ^ commandID is the parent such as 1100 (or whatever UI_RECENTMENU is)
// ge->Caller->getText() // Don't do this. Caller is the parent!
this->openRecent(callerID, menu->getItemText(selected));
// cerr << " commandID: " << commandID << std::endl;
// selectedItemID is a sequential number.
// commandID is a menu id specified on create such as starting from 1101
// (or from whatever UIC_FILE_RECENT_FIRST is--usually UI_RECENTMENU+1)
// std::wstring menuItemText = menu->getItemText(selected);
this->openRecent(selected);
}
else {
cerr << "Unknown item id: " << selected << " Text:" << Utility::toString(menu->getItemText(selected)) << endl;
cerr << "Unknown selected id: " << selected << " Text:" << Utility::toString(menu->getItemText(selected)) << endl;
if (this->recentIndices.size() < 1) {
cerr << "- recentIndices.size(): " << recentIndices.size() << endl;
}
@ -362,7 +368,7 @@ bool UserInterface::handleMenuItemPressed(const SEvent::SGUIEvent* ge)
handled = false;
}
// cerr << "[UserInterface::handleMenuItemPressed] Unknown caller id: " << id << endl;
// cerr << "[UserInterface::handleMenuItemPressed] Unknown caller id: " << callerID << endl;
break;
default:
//if (selected > -1) {
@ -371,7 +377,7 @@ bool UserInterface::handleMenuItemPressed(const SEvent::SGUIEvent* ge)
<< std::endl;
cerr << " - checking command id..."
<< std::endl;
switch (id) {
switch (commandID) {
case UIC_FILE_OPEN:
displayLoadFileDialog();
break;
@ -498,7 +504,7 @@ bool UserInterface::handleMenuItemPressed(const SEvent::SGUIEvent* ge)
);
break;
default:
cerr << "Unknown command id: " << id << " Text:" << Utility::toString(menu->getItemText(selected)) << endl;
cerr << "Unknown command id: " << commandID << " Text:" << Utility::toString(menu->getItemText(selected)) << endl;
break;
}
break;
@ -914,16 +920,47 @@ bool UserInterface::hasRecent(std::string path)
return false;
}
void UserInterface::openRecent(s32 menuID, std::wstring menuText)
bool UserInterface::openRecent(s32 selectedItemID)
{
bool result = false;
if (!this->recent_initialized) {
throw std::runtime_error("The UI is not ready in addRecent.");
}
IGUIElement* menu = this->recentMenu->getElementFromId(menuID);
std::string path = Utility::toString(menu->getText());
cerr << "path: " << path << endl;
cerr << "menuID: " << menuID << endl;
cerr << "menuText: " << Utility::toString(menuText) << endl;
// IGUIElement* submenu = this->recentMenu->getElementFromId(commandID);
// ^ There is no element for menuID (such as 1100) nor for commandID (such as 1)
// IGUIElement* submenu = this->recentMenu->getSubMenu(selectedItemID);
// ^ There is no submenu for selectedItemID (such as 1)
// IGUIElement* submenu = this->recentMenu->getSubMenu(commandID);
// ^ There is no submenu for commandID (such as 1101)
// IGUIElement* submenu = this->menu->getElementFromId(commandID);
// ^ There is no elemend for commandID (such as 1101)
// IGUIElement* submenu = this->menu->getElementFromId(selectedItemID);
// ^ There is no element for selectedItemID (such as 1)
// IGUIElement* submenu = this->menu->getSubMenu(commandID);
// ^ There is no submenu for commandID (such as 1101)
IGUIElement* submenu = this->menu->getSubMenu(selectedItemID);
if (submenu != nullptr) {
std::wstring menuText = this->recentMenu->getItemText(selectedItemID);
// std::string path = Utility::toString(submenu->getText());
// ^ blank
std::string path = Utility::toString(menuText); // blank
cerr << "path: " << path << endl;
cerr << "selectedItemID: " << selectedItemID << endl;
cerr << "menuText: " << Utility::toString(menuText) << endl;
result = m_Engine->loadMesh(menuText);
if (!result) {
this->m_Engine->m_Device->getGUIEnvironment()->addMessageBox(
L"Load Mesh", L"The model is inaccessible or not in a compatible format.");
}
}
else {
cerr << "[UserInterface::openRecent] Error: There is no submenu for selectedItemID " << selectedItemID << std::endl;
// for (auto it : this->recentMenu->getChildren()) {
// cerr << " - " << it << std::endl;
// }
// ^ iterates 0 times; ranged for
}
return result;
}
// IEventReceiver

View File

@ -135,7 +135,7 @@ public:
void addRecentMenuItem(std::string path, bool addToEngine);
void addRecentMenuItems(std::vector<std::string> paths, bool addToEngine);
bool hasRecent(std::string path);
void openRecent(irr::s32 menuID, std::wstring menuText);
bool openRecent(irr::s32 selectedItemID);
bool OnSelectMesh();
void setPlaybackText(irr::s32 id, const wchar_t* str);

View File

@ -91,7 +91,7 @@ g++ -o build/b3view $OBJDIR/main.o $OBJDIR/Engine.o $OBJDIR/EventHandler.o $OBJ
if [ $? -ne 0 ]; then
echo "* linking failed."
else
echo "* linking suceeded."
echo "* linking succeeded."
fi
if [ ! -f "$OUT_BIN" ]; then
echo "Error: $OUT_BIN couldn't be built."
@ -112,12 +112,11 @@ if [ "@$RUN_DEBUG" = "@true" ]; then
fi
else
echo " (add the --run-debug option to run it automatically)"
exit 0
fi
if [ "@$DEBUG" != "@true" ]; then
if [ -f "$INSTALLED_BIN" ]; then
echo "* updating $INSTALLED_BIN..."
./$OUT_BIN
./$OUT_BIN --test-and-quit
if [ $? -eq 0 ]; then
# if no errors occur, install it
rm "$INSTALLED_BIN"
@ -139,5 +138,8 @@ if [ "@$DEBUG" != "@true" ]; then
# cat ./debug-and-show-tb.sh
# echo " gdb \"$OUT_BIN\""
fi
else
echo "* skipping \"$INSTALLED_BIN\" update since it doesn't exist"
fi
fi
echo "Done"

View File

@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [git] - 2021-02-22
### Added
- Recent menu item loading (not completely implemented in previous commits).
### Fixed
- identification of recent menu items
## [git] - 2021-02-21
### Added
- codeblocks support
### Fixed
- paths in shell script
## [git] - 2021-02-17
### Added
- a settings system and related tests
@ -236,4 +252,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Added
- .gitignore (a [Qt .gitignore](https://github.com/github/gitignore/blob/master/Qt.gitignore))
- CHANGELOG.md
- changelog.md

View File

@ -10,13 +10,23 @@ bat: [github.com/poikilos/mobs_sky](https://github.com/poikilos/mobs_sky)
Website: [poikilos.org](https://poikilos.org)
## Requirements
* libirrlicht
(or libirrlicht1.8)
- libirrlicht (such as libirrlicht1.8 and libirrlicht-dev on Debian 10)
- freetype (such as libfreetype6 and libfreetype6-dev on Debian 10)
- If using **Code::Blocks**, add the following 2 variables in "Settings," "Global variables":
- freetype
- base: /usr/include/freetype2
- include: /usr/include/freetype2
- lib: /usr/lib/x86_64-linux-gnu
- irrlicht
- base: /usr/include/irrlicht
- include: /usr/include/irrlicht
- lib: /usr/lib/x86_64-linux-gnu
If not using Code::Blocks, compile using the included `./build.sh` (requires bash or a shell that can handle the `if` syntax).
### Development
* libirrlicht-dbg
(or libirrlicht1.8-dbg)
* If necessary, set "NOT_ISO_CPP17" flag during compilation to make some special preprocessors in the code change `<filesystem>` to `<experimental/filesystem>` and `namespace fs = std::filesystem;` to `namespace fs = std::experimental::filesystem;`.
* libirrlicht-dbg (such as libirrlicht1.8-dbg on Debian 10)
* libfreetype6-dev
- In CodeBlocks (once per computer): Settings, Compiler, Search paths, /usr/include/freetype2
- Ensure includes do not put freetype2 first (that directory contains freetype and ft2build.h. Also, freetype itself does its includes as freetype not freetype2/freetype).
@ -36,7 +46,7 @@ CodeBlocks says it is looking for boost_filesystem and boost_system, which may b
Systems--see Compile and Install)
* hotkeys to cycle through textures and reload model OR texture
(see [Usage](#Usage) below).
* see also CHANGELOG.md
* see also changelog.md
* export feature: COLLADA (non-Blender), IRR (Irrlicht Scene settings
and mesh file paths only), IRRMESH (Static Irrlicht Mesh), OBJ
(Wavefront), STL (stereolithography)