Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quest Menu Changes #120

Merged
merged 1 commit into from
Jan 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions dat/config/quests.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
-- this is a flat list of all the quest descriptions and their titles.
-- format should be as follows: ["unique_string_id"] = {"title", "description", completion_event_group, completion_event_name, location_name, location_banner_filename},
-- format should be as follows: ["unique_string_id"] =
-- {"title", "description", completion_description, completion_event_group, completion_event_name, location_name, location_banner_filename, location_subname, location_subimage},
-- When the event value of the completion_event_name in the completion_event_group is equal to 1, the quest is considered complete.
-- location_name and location_banner_filename are optional fields, and they are used to display the quest start location and associated banner image
-- location_name, location_subname, location_subimage and location_banner_filename are optional fields, and they are used to display the quest start location and associated banner image
-- All fields can be empty but are required.

-- Use the 'GlobalManager:AddQuestLog("string_id");' luabind script command to add a quest entry in the player's quest log.
Expand All @@ -13,10 +14,14 @@ quests = {
hoa_system.Translate("Get Some Barley Meal"),
-- Description
hoa_system.Translate("Mom needs some for dinner!\n \nFlora might have some in her shop. I should go and have a look there first."),
-- Completion Description
hoa_system.Translate("This quest is completed. Here's how i did it:\nblah blah blah..."),
-- Group and event for the quest to be complete.
"story", "quest1_barley_meal_done",
-- Location name and banner image filename
hoa_system.Translate("Village of Layna\n \nBronann's home"), "img/menus/locations/mountain_village.png"
hoa_system.Translate("Village of Layna"), "img/menus/locations/mountain_village.png",
-- Location sub-name and image filename
hoa_system.Translate("Bronann's home"), "img/menus/locations/mountain_village.png",
},

-- Quest id
Expand All @@ -25,10 +30,14 @@ quests = {
hoa_system.Translate("Find Georges' pen"),
-- Description
hoa_system.Translate("In order to know whom Georges gave the rest of barley meal to, I need to get back his lost pen.\n \nHe spoke about losing it near a tree but also told me people in the village might know more..."),
-- Completion Description
hoa_system.Translate("This quest is completed. Here's how i did it:\nblah blah blah..."),
-- Group and event for the quest to be complete.
"layna_center", "quest1_pen_given_done",
-- Location name and banner image filename
hoa_system.Translate("Village of Layna\n \nVillage center"), "img/menus/locations/mountain_village.png"
hoa_system.Translate("Village of Layna"), "img/menus/locations/mountain_village.png",
-- Location sub-name and image filename
hoa_system.Translate("Village center"), "img/menus/locations/mountain_village.png",
},

-- Quest id
Expand All @@ -37,10 +46,14 @@ quests = {
hoa_system.Translate("Let's go in the woods..."),
-- Description
hoa_system.Translate("It's been weeks since I could go outside the village.\n \nThe entrance has been shut with stones, and now they won't even let me go and breath in the only place I could still go before?!?\n \nWhatever, I need a sword just in case and I'll get there alone!"),
-- Completion Description
hoa_system.Translate("This quest is completed. Here's how i did it:\nblah blah blah..."),
-- Group and event for the quest to be complete.
"story", "kalya_has_joined",
-- Location name and banner image filename
hoa_system.Translate("Village of Layna\n \nBronann's home"), "img/menus/locations/mountain_village.png"
hoa_system.Translate("Village of Layna"), "img/menus/locations/mountain_village.png",
-- Location sub-name and image filename
hoa_system.Translate("Bronann's home"), "img/menus/locations/mountain_village.png",
},

-- Quest id
Expand All @@ -49,9 +62,13 @@ quests = {
hoa_system.Translate("Orlinn might be in danger!"),
-- Description
hoa_system.Translate("After seeing that strange light, Orlinn just ran away into the woods. He's just a kid, even if a quick one!\n \nMy own father asked me to go there with Kalya and get him back safe and sound.\n \nI can't let them down!"),
-- Completion Description
hoa_system.Translate("This quest is completed. Here's how i did it:\nblah blah blah..."),
-- Group and event for the quest to be complete.
"none", "none",
-- Location name and banner image filename
hoa_system.Translate("Village of Layna\n \nVillage center"), "img/menus/locations/mountain_village.png"
hoa_system.Translate("Village of Layna"), "img/menus/locations/mountain_village.png",
-- Location sub-name and image filename
hoa_system.Translate("Village center"), "img/menus/locations/mountain_village.png",
}
}
8 changes: 5 additions & 3 deletions src/common/global/global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1680,12 +1680,14 @@ bool GameGlobal::_LoadQuestsScript(const std::string& quests_script_filename)
}

//check whether all fields are there.
if(quest_info.size() == 6)
if(quest_info.size() == 9)
{
QuestLogInfo info = QuestLogInfo(MakeUnicodeString(quest_info[0]),
MakeUnicodeString(quest_info[1]),
quest_info[2], quest_info[3],
MakeUnicodeString(quest_info[4]), quest_info[5]);
MakeUnicodeString(quest_info[2]),
quest_info[3], quest_info[4],
MakeUnicodeString(quest_info[5]), quest_info[6],
MakeUnicodeString(quest_info[7]), quest_info[8]);
_quest_log_info[quest_id] = info;
}
//malformed quest log
Expand Down
33 changes: 31 additions & 2 deletions src/common/global/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,43 @@ struct QuestLogEntry
struct QuestLogInfo {
QuestLogInfo(const hoa_utils::ustring &title,
const hoa_utils::ustring &description,
const hoa_utils::ustring &completion_description,
const std::string &completion_event_group,
const std::string &completion_event_name,
const hoa_utils::ustring &location_name,
const std::string &location_banner_filename) :
const std::string &location_banner_filename,
const hoa_utils::ustring &location_subname,
const std::string &location_subimage_filename) :
_title(title),
_description(description),
_completion_description(completion_description),
_completion_event_group(completion_event_group),
_completion_event_name(completion_event_name),
_location_name(location_name)
_location_name(location_name),
_location_subname(location_subname)
{
if(!_location_image.Load(location_banner_filename))
{
PRINT_ERROR << "image: " << location_banner_filename << " not able to load" << std::endl;
return;
}
//rescale such that the height is no bigger than 90 pixels. we give ourselves a bit of wiggle room
//by actually setting it to 90px, 5 pixel buffer top and bottom, so that we can utilize a potential 100px
if(_location_image.GetHeight() > 90.0f)
_location_image.SetHeightKeepRatio(90.0f);

if(!_location_subimage.Load(location_subimage_filename))
{
PRINT_ERROR << "image: " << location_subimage_filename << " not able to load" << std::endl;
return;
}
//rescale such that the height is no bigger than 90 pixels. we give ourselves a bit of wiggle room
//by actually setting it to 90px, 5 pixel buffer top and bottom, so that we can utilize a potential 100px
if(_location_subimage.GetHeight() > 90.0f)
_location_subimage.SetHeightKeepRatio(90.0f);



}

QuestLogInfo()
Expand All @@ -217,14 +242,18 @@ struct QuestLogInfo {
// User info about the quest log
hoa_utils::ustring _title;
hoa_utils::ustring _description;
// Completion description gets added to the quest description when the quest is considered completed
hoa_utils::ustring _completion_description;

// Internal quest info used to know whether the quest is complete.
std::string _completion_event_group;
std::string _completion_event_name;

// location information
hoa_video::StillImage _location_image;
hoa_video::StillImage _location_subimage;
hoa_utils::ustring _location_name;
hoa_utils::ustring _location_subname;
};

/** *****************************************************************************
Expand Down
89 changes: 68 additions & 21 deletions src/modes/menu/menu_views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,13 +1699,21 @@ void QuestListWindow::_UpdateQuestList()

QuestLogEntry *entry = _quest_entries[selection];
const std::string& quest_id = entry->GetQuestId();

if (!entry->IsRead()) {
ustring title = GlobalManager->GetQuestInfo(quest_id)._title;
ustring title = GlobalManager->GetQuestInfo(quest_id)._title;
if(GlobalManager->IsQuestCompleted(quest_id))
{
_quests_list.SetOptionText(selection, check_file + title);
_quests_list.SetCursorOffset(-55.0f, -15.0f);
_quests_list.EnableOption(selection, false);
}
else
{
_quests_list.SetCursorOffset(-75.0f, -15.0f);
_quests_list.SetOptionText(selection, spacing + title);
entry->SetRead();
}

entry->SetRead();

// Update the list box
_quests_list.Update(SystemManager->GetUpdateTime());

Expand Down Expand Up @@ -1746,16 +1754,16 @@ void QuestListWindow::_SetupQuestsList() {
const std::string& quest_id = entry->GetQuestId();
ustring title = GlobalManager->GetQuestInfo(quest_id)._title;

if(entry->IsRead())
_quests_list.AddOption(spacing + title);
else
_quests_list.AddOption(exclamation_file + title);

// Check if this is a completed quest, and set the option text state
//completed quest check.
if(GlobalManager->IsQuestCompleted(quest_id)) {
_quests_list.SetOptionText(i, check_file + title);
_quests_list.AddOption(check_file + title);
_quests_list.EnableOption(i, false);
}
//if incomplete, then we check the read status
else if(entry->IsRead())
_quests_list.AddOption(spacing + title);
else
_quests_list.AddOption(exclamation_file + title);
}
}

Expand All @@ -1764,44 +1772,73 @@ void QuestListWindow::_SetupQuestsList() {
////////////////////////////////////////////////////////////////////////////////

QuestWindow::QuestWindow():
_location_image(NULL)
_location_image(NULL),
_location_subimage(NULL)
{
//_quest_description.SetOwner(this);
_quest_description.SetPosition(445, 130);
_quest_description.SetDimensions(455, 400);
_quest_description.SetDisplaySpeed(30);
_quest_description.SetDimensions(455, 200);
_quest_description.SetDisplayMode(VIDEO_TEXT_INSTANT);
_quest_description.SetTextStyle(TextStyle("text20"));
_quest_description.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);

// preferably, we want the completion description to show underneath the description text
// last line. Unfortunatly, it seems CalculateTextHeight() doesn't work right
// so we fix the position for now
_quest_completion_description.SetPosition(445, 350);
_quest_completion_description.SetDimensions(455, 200);
_quest_completion_description.SetDisplayMode(VIDEO_TEXT_INSTANT);
_quest_completion_description.SetTextStyle(TextStyle("text20", Color::aqua));
_quest_completion_description.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);

_location_name.SetPosition(102, 556);
_location_name.SetDimensions(500.0f, 150.0f);
_location_name.SetTextStyle(TextStyle("text22"));
_location_name.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
_location_name.SetDisplayText(GlobalManager->GetMapHudName());
_location_name.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
_location_name.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);

_location_subname.SetPosition(500, 556);
_location_subname.SetDimensions(500.0f, 150.0f);
_location_subname.SetTextStyle(TextStyle("text22"));
_location_subname.SetAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);
_location_subname.SetTextAlignment(VIDEO_X_LEFT, VIDEO_Y_TOP);


}

void QuestWindow::Draw()
{
MenuWindow::Draw();
Update();
if(MenuMode::CurrentInstance()->_quest_list_window.IsActive())
{
_quest_description.Draw();
_quest_completion_description.Draw();
}

}

void QuestWindow::DrawBottom()
{
VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
VideoManager->Move(150, 580);
// Display Location
// Display Location name information
_location_name.Draw();
_location_subname.Draw();


//check location image and draw
if(_location_image != NULL && _location_image->GetFilename().empty() == false) {
VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_BOTTOM, 0);
VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
VideoManager->Move(390, 685);
VideoManager->Move(102, 685);
_location_image->Draw();
}

//check location subimage and draw
if(_location_subimage != NULL && _location_subimage->GetFilename().empty() == false) {
VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_BOTTOM, 0);
VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
VideoManager->Move(500, 685);
_location_subimage->Draw();
}
}

void QuestWindow::Update()
Expand All @@ -1812,7 +1849,9 @@ void QuestWindow::Update()
if(_viewing_quest_id.empty()) {
_quest_description.ClearText();
_location_name.ClearText();
_location_subname.ClearText();
_location_image = NULL;
_location_subimage = NULL;
return;
}

Expand All @@ -1823,7 +1862,15 @@ void QuestWindow::Update()
{
_quest_description.SetDisplayText(info._description);
_location_name.SetDisplayText(info._location_name);
_location_subname.SetDisplayText(info._location_subname);
_location_image = &info._location_image;
_location_subimage = &info._location_subimage;

//set the completion description only if the quest is completed
if(GlobalManager->IsQuestCompleted(_viewing_quest_id))
_quest_completion_description.SetDisplayText(info._completion_description);
else
_quest_completion_description.ClearText();
}

}
Expand Down
10 changes: 8 additions & 2 deletions src/modes/menu/menu_views.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,9 @@ class QuestWindow : public hoa_gui::MenuWindow {
void ClearBottom()
{
_location_name.ClearText();
_location_subname.ClearText();
_location_image = NULL;
_location_subimage = NULL;
}

/*!
Expand All @@ -603,12 +605,16 @@ class QuestWindow : public hoa_gui::MenuWindow {

//! \brief sets the display text to be rendered, based on their quest key that is set
hoa_gui::TextBox _quest_description;
//! \brief sets the display text to be rendered when the quest is completed. this is additional info
hoa_gui::TextBox _quest_completion_description;

//! \brief the display text to be rendered for the location name that the quest key is set to
//! \brief the display text to be rendered for the location name and subname that the quest key is set to
hoa_gui::TextBox _location_name;
hoa_gui::TextBox _location_subname;

//! \brief the currently viewing location image
//! \brief the currently viewing location image and location subimage
hoa_video::StillImage *_location_image;
hoa_video::StillImage *_location_subimage;

};

Expand Down