assert(!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject());\r
});\r
\r
+ auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
+ ptr->set_icon_image_handle(\r
+ ResourceManager::LoadCachedGraph(unicode::ToTString(source_folder_ + "/" + icon_)));\r
}\r
\r
Card::~Card()\r
{\r
MMO_PROFILE_FUNCTION;\r
\r
- static int cnt = 0;\r
- if (!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject()) {\r
- auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
- if (ptr->children_size() > 0) {\r
- ptr->Update();\r
- if (cnt % 2 == 0) {\r
- ptr->AsyncUpdate();\r
- }\r
- }\r
- }\r
- cnt++;\r
+ // static int cnt = 0;\r
+ // if (!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject()) {\r
+ //auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
+ //if (ptr->children_size() > 0) {\r
+ // ptr->Update();\r
+ // if (cnt % 2 == 0) {\r
+ // ptr->AsyncUpdate();\r
+ // }\r
+ //}\r
+ // }\r
+ // cnt++;\r
}\r
\r
void Card::Draw()\r
{\r
MMO_PROFILE_FUNCTION;\r
\r
- if (!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject()) {\r
- auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
+ // if (!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject()) {\r
+ // auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
\r
- if (ptr->children_size() > 0) {\r
- ptr->Draw();\r
- }\r
- }\r
+ // if (ptr->children_size() > 0) {\r
+ //ptr->Draw();\r
+ // }\r
+ // }\r
}\r
\r
UIBasePtr Card::GetWindow() const\r
// CheckFunctionKey(KEY_INPUT_F11, "F11", *input);\r
// CheckFunctionKey(KEY_INPUT_F12, "F12", *input);\r
\r
- script_.With([&](const Handle<Context>& context){\r
- if (!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject()) {\r
- auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
- if (ptr->children_size() > 0) {\r
- ptr->ProcessInput(input);\r
- }\r
- }\r
- });\r
+ //script_.With([&](const Handle<Context>& context){\r
+ // if (!ui_board_obj_.IsEmpty() && ui_board_obj_->IsObject()) {\r
+ // auto ptr = *static_cast<UIBasePtr*>(ui_board_obj_->GetPointerFromInternalField(0));\r
+ // if (ptr->children_size() > 0) {\r
+ // ptr->ProcessInput(input);\r
+ // }\r
+ // }\r
+ //});\r
}\r
\r
void Card::CheckFunctionKey(int keynum, const std::string& name, const InputManager& input)\r
return -1;\r
}\r
\r
+ScriptEnvironment& Card::script()\r
+{\r
+ return script_;\r
+}\r
+\r
void Card::set_max_local_storage_size(int size)\r
{\r
max_local_storage_size = size;\r
WindowManager::WindowManager(const ManagerAccessorPtr& manager_accessor) :
manager_accessor_(manager_accessor)
{
-
+ close_button_image_handle_ =
+ ResourceManager::LoadCachedGraph(_T("resources/images/gui/gui_close_button.png"));
+ icon_base_image_handle_ =
+ ResourceManager::LoadCachedGraph(_T("resources/images/gui/gui_icon_base.png"));
}
void WindowManager::Init()
void WindowManager::ProcessInput(InputManager* input)
{
+ closed_windows_.clear();
+
BOOST_FOREACH(const auto& window, windows_) {
if (auto ptr = window.lock()) {
- ptr->ProcessInput(input);
+ int x = ptr->absolute_x() - 12;
+ int y = ptr->absolute_y() - 12;
+
+ bool hover = (x <= input->GetMouseX() && input->GetMouseX() <= x + 30
+ && y <= input->GetMouseY() && input->GetMouseY() <= y + 30);
+
+ if (hover && input->GetMouseLeftCount() == 1) {
+ ptr->set_visible(false);
+ input->CancelMouseLeft();
+ }
+
+ if (ptr->visible()) {
+ ptr->ProcessInput(input);
+ } else {
+ closed_windows_.push_back(ptr);
+ }
}
}
auto card_manager = manager_accessor_->card_manager().lock();
BOOST_FOREACH(const auto& card, card_manager->cards()) {
if (auto ptr = card->GetWindow()) {
- // ptr->ProcessInput(input);
+ int x = ptr->absolute_x() - 12;
+ int y = ptr->absolute_y() - 12;
+
+ bool hover = (x <= input->GetMouseX() && input->GetMouseX() <= x + 30
+ && y <= input->GetMouseY() && input->GetMouseY() <= y + 30);
+
+ if (hover && input->GetMouseLeftCount() == 1) {
+ ptr->set_visible(false);
+ input->CancelMouseLeft();
+ }
+
+ if (ptr->visible()) {
+ card->script().With([&](const Handle<Context>& context)
+ {
+ ptr->ProcessInput(input);
+ });
+ } else {
+ closed_windows_.push_back(ptr);
+ }
}
}
}
auto card_manager = manager_accessor_->card_manager().lock();
BOOST_FOREACH(const auto& card, card_manager->cards()) {
if (auto ptr = card->GetWindow()) {
- // ptr->Update();
+ ptr->Update();
}
}
}
{
BOOST_FOREACH(const auto& window, windows_) {
if (auto ptr = window.lock()) {
- ptr->Draw();
+ if (ptr->visible()) {
+ ptr->Draw();
+ }
}
}
auto card_manager = manager_accessor_->card_manager().lock();
BOOST_FOREACH(const auto& card, card_manager->cards()) {
if (auto ptr = card->GetWindow()) {
- // ptr->Draw();
+ if (ptr->visible()) {
+ ptr->Draw();
+ }
}
}
}
+void WindowManager::DrawButtons()
+{
+ BOOST_FOREACH(const auto& window, windows_) {
+ if (auto ptr = window.lock()) {
+ if (ptr->visible()) {
+ int x = ptr->absolute_x() - 12;
+ int y = ptr->absolute_y() - 12;
+
+ DrawGraph(x, y, *close_button_image_handle_, TRUE);
+ }
+ }
+ }
+
+ auto card_manager = manager_accessor_->card_manager().lock();
+ BOOST_FOREACH(const auto& card, card_manager->cards()) {
+ if (auto ptr = card->GetWindow()) {
+ if (ptr->visible()) {
+ int x = ptr->absolute_x() - 12;
+ int y = ptr->absolute_y() - 12;
+
+ DrawGraph(x, y, *close_button_image_handle_, TRUE);
+ }
+ }
+ }
+}
+
+
+void WindowManager::DrawIcons(const Rect& rect)
+{
+ int x = 32;
+ BOOST_FOREACH(const auto& window, closed_windows_) {
+ if (auto ptr = window.lock()) {
+ ImageHandlePtr image_handle;
+ if (auto custom_icon = ptr->icon_image_handle()) {
+ image_handle = custom_icon;
+ } else {
+ image_handle = icon_base_image_handle_;
+ }
+ DrawGraph(rect.x + x, rect.y + 100 + 4, *image_handle, TRUE);
+ x += 64;
+ }
+ }
+}
+
+void WindowManager::ProcessInputIcons(const Rect& rect, InputManager* input)
+{
+ int x = 32;
+ BOOST_FOREACH(const auto& window, closed_windows_) {
+ if (auto ptr = window.lock()) {
+
+ int icon_x = rect.x + x;
+ int icon_y = rect.y + 100 + 4;
+
+ bool hover = (icon_x <= input->GetMouseX() && input->GetMouseX() <= icon_x + 48
+ && icon_y <= input->GetMouseY() && input->GetMouseY() <= icon_y + 48);
+
+ if (hover && input->GetMouseLeftCount() == 1) {
+ ptr->set_visible(true);
+ input->CancelMouseLeft();
+ }
+ x += 64;
+ }
+ }
+}
+
+
void WindowManager::AddWindow(const UISuperPtr& window)
{
windows_.push_back(window);
#pragma once
#include "ManagerAccessor.hpp"
+#include "ResourceManager.hpp"
#include "ui/UISuper.hpp"
#include <vector>
void ProcessInput(InputManager* input);
void Update();
void Draw();
+
+ void DrawButtons();
+ void DrawIcons(const Rect& rect);
+ void ProcessInputIcons(const Rect& rect, InputManager* input);
void AddWindow(const UISuperPtr& window);
private:
ManagerAccessorPtr manager_accessor_;
+ ImageHandlePtr close_button_image_handle_;
+ ImageHandlePtr icon_base_image_handle_;
std::vector<UISuperWeakPtr> windows_;
+ std::vector<UISuperWeakPtr> closed_windows_;
};
typedef std::shared_ptr<WindowManager> WindowManagerPtr;
--- /dev/null
+//
+// Dashboard.cpp
+//
+
+#include "Dashboard.hpp"
+#include "../ManagerAccessor.hpp"
+#include "../AccountManager.hpp"
+#include "../CommandManager.hpp"
+#include "../PlayerManager.hpp"
+#include "../CardManager.hpp"
+#include "../AccountManager.hpp"
+#include "../WindowManager.hpp"
+
+namespace scene {
+
+const int Dashboard::TAB_BLOCK_HEIGHT = 32;
+const int Dashboard::TAB_BLOCK_WIDTH = 128;
+
+Dashboard::Dashboard(const ManagerAccessorPtr& manager_accessor,
+ const BasePtr& background_scene) :
+ manager_accessor_(manager_accessor),
+ config_manager_(manager_accessor->config_manager().lock()),
+ card_manager_(manager_accessor->card_manager().lock()),
+ account_manager_(manager_accessor->account_manager().lock()),
+ window_manager_(manager_accessor->window_manager().lock()),
+ background_scene_(background_scene),
+ start_count_(0),
+ end_count_(0)
+{
+ manager_accessor_->set_window_manager(WindowManagerWeakPtr());
+
+ manager_accessor_->set_config_manager(config_manager_);
+ manager_accessor_->set_card_manager(card_manager_);
+ manager_accessor_->set_account_manager(account_manager_);
+
+ base_image_handle_ = ResourceManager::LoadCachedDivGraph<4>(
+ _T("resources/images/gui/gui_option_base.png"), 2, 2, 96, 96);
+
+ tab_base_image_handle_ = ResourceManager::LoadCachedDivGraph<3>(
+ _T("resources/images/gui/gui_option_tab_base.png"), 1, 3, 128, 32);
+
+}
+
+Dashboard::~Dashboard()
+{
+}
+
+void Dashboard::Begin()
+{
+}
+
+void Dashboard::Update()
+{
+ if (end_count_ > 0) {
+ end_count_++;
+ } else {
+ start_count_++;
+ }
+
+ if (background_scene_) {
+ background_scene_->Update();
+ }
+
+ int screen_width, screen_height;
+ GetScreenState(&screen_width, &screen_height, nullptr);
+
+ if (end_count_ > 0) {
+ bg_alpha_ = 150 * ((10 - end_count_) / 10.0);
+ } else {
+ bg_alpha_ = 150 * (start_count_ / 10.0);
+ }
+ bg_alpha_ = std::min(150, bg_alpha_);
+
+ base_rect_.width = 800;
+ base_rect_.height = 160;
+ base_rect_.x = (screen_width - base_rect_.width) / 2;
+
+ if (end_count_ > 0) {
+ base_rect_.y = -100 - base_rect_.height * (end_count_ / 10.0);
+ } else {
+ base_rect_.y = -100 - base_rect_.height * ((10 - start_count_) / 10.0);
+ }
+ base_rect_.y = std::min(-100, base_rect_.y);
+
+ window_manager_->Update();
+}
+
+void Dashboard::ProcessInput(InputManager* input)
+{
+ window_manager_->ProcessInputIcons(base_rect_, input);
+ window_manager_->ProcessInput(input);
+
+ bool hover = (base_rect_.x <= input->GetMouseX() && input->GetMouseX() <= base_rect_.x + base_rect_.width
+ && base_rect_.y <= input->GetMouseY() && input->GetMouseY() <= base_rect_.y + base_rect_.height);
+
+ if (input->GetKeyCount(KEY_INPUT_F2) == 1 ||
+ input->GetKeyCount(KEY_INPUT_ESCAPE) == 1 ||
+ (!hover && (input->GetMouseLeftCount() == 1 || input->GetMouseRightCount() == 1))) {
+ end_count_++;
+ }
+}
+
+void Dashboard::Draw()
+{
+ if (background_scene_) {
+ background_scene_->Draw();
+ }
+
+ int screen_width, screen_height;
+ GetScreenState(&screen_width, &screen_height, nullptr);
+
+ SetDrawBlendMode(DX_BLENDMODE_ALPHA, bg_alpha_);
+
+ DrawBox(0, 0, screen_width, screen_height, GetColor(0, 0, 0), TRUE);
+ SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
+
+ window_manager_->Draw();
+
+ SetDrawBlendMode(DX_BLENDMODE_ALPHA, bg_alpha_ * 255 / 150);
+ window_manager_->DrawButtons();
+ SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
+
+ int BASE_BLOCK_SIZE = 96;
+
+ int x = base_rect_.x - 32;
+ int y = base_rect_.y;
+ int width = base_rect_.width + 64;
+ int height = base_rect_.height + 32;
+
+ DrawGraph(x, y, *base_image_handle_[0], TRUE);
+ DrawGraph(x + width - BASE_BLOCK_SIZE, y, *base_image_handle_[1], TRUE);
+ DrawGraph(x, y + height - BASE_BLOCK_SIZE, *base_image_handle_[2], TRUE);
+ DrawGraph(x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
+
+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y,
+ x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
+ 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[1], TRUE);
+
+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
+ x + width - BASE_BLOCK_SIZE, y + height,
+ 0, 0, 1, BASE_BLOCK_SIZE, *base_image_handle_[3], TRUE);
+
+ DrawRectExtendGraphF(x, y + BASE_BLOCK_SIZE,
+ x + BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
+ 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[2], TRUE);
+
+ DrawRectExtendGraphF(x + width - BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
+ x + width, y + height - BASE_BLOCK_SIZE,
+ 0, 0, BASE_BLOCK_SIZE, 1, *base_image_handle_[3], TRUE);
+
+ DrawRectExtendGraphF(x + BASE_BLOCK_SIZE, y + BASE_BLOCK_SIZE,
+ x + width - BASE_BLOCK_SIZE, y + height - BASE_BLOCK_SIZE,
+ 0, 0, 1, 1, *base_image_handle_[3], TRUE);
+
+ window_manager_->DrawIcons(base_rect_);
+
+}
+
+void Dashboard::End()
+{
+
+}
+
+BasePtr Dashboard::NextScene()
+{
+ if (end_count_ > 10) {
+ manager_accessor_->set_window_manager(window_manager_);
+ return background_scene_;
+ } else {
+ return BasePtr();
+ }
+}
+}
\ No newline at end of file
--- /dev/null
+//
+// Dashboard.hpp
+//
+
+#pragma once
+
+#include <boost/property_tree/json_parser.hpp>
+#include "Base.hpp"
+#include "../ManagerHeader.hpp"
+#include "../ManagerAccessor.hpp"
+#include "../ResourceManager.hpp"
+#include "../ui/UISuper.hpp"
+
+using namespace boost::property_tree;
+
+namespace scene {
+
+class Dashboard : public Base {
+ public:
+ Dashboard(const ManagerAccessorPtr& manager_accessor,
+ const BasePtr& background_scene);
+ ~Dashboard();
+ void Begin();
+ void Update();
+ void ProcessInput(InputManager*);
+ void Draw();
+ void End();
+ BasePtr NextScene();
+
+ private:
+ ManagerAccessorPtr manager_accessor_;
+ ConfigManagerPtr config_manager_;
+ CardManagerPtr card_manager_;
+ AccountManagerPtr account_manager_;
+ WindowManagerPtr window_manager_;
+
+ BasePtr background_scene_;
+
+ int start_count_;
+ int end_count_;
+
+ int bg_alpha_;
+ Rect base_rect_;
+ std::array<ImageHandlePtr,4> base_image_handle_;
+ std::array<ImageHandlePtr,3> tab_base_image_handle_;
+
+ private:
+ static const int TAB_BLOCK_HEIGHT;
+ static const int TAB_BLOCK_WIDTH;
+};
+
+}
\ No newline at end of file
#include "MainLoop.hpp"
#include "Option.hpp"
+#include "Dashboard.hpp"
#include <vector>
#include <algorithm>
#include "../ResourceManager.hpp"
manager_accessor_->set_window_manager(window_manager_);
inputbox_->ReloadTabs();
+ inputbox_->Activate();
+ inputbox_->set_icon_image_handle(
+ ResourceManager::LoadCachedGraph(_T("resources/images/gui/gui_icon_input.png")));
+
window_manager_->AddWindow(inputbox_);
minimap_->UIPlacement(config_manager_->screen_width() - MINIMAP_MINSIZE - 12, 12);
+ minimap_->set_icon_image_handle(
+ ResourceManager::LoadCachedGraph(_T("resources/images/gui/gui_icon_map.png")));
window_manager_->AddWindow(minimap_);
player_manager_->Init();
void MainLoop::Update()
{
- window_manager_->Update();
+ if (auto window_manager = manager_accessor_->window_manager().lock()) {
+ window_manager->Update();
+ }
command_manager_->Update();
player_manager_->Update();
card_manager_->Update();
void MainLoop::ProcessInput(InputManager* input)
{
- window_manager_->ProcessInput(input);
+ if (auto window_manager = manager_accessor_->window_manager().lock()) {
+ window_manager->ProcessInput(input);
+ }
player_manager_->ProcessInput(input);
card_manager_->ProcessInput(input);
world_manager_->ProcessInput(input);
world_manager_->Draw();
player_manager_->Draw();
card_manager_->Draw();
- window_manager_->Draw();
+ if (auto window_manager = manager_accessor_->window_manager().lock()) {
+ window_manager->Draw();
+ }
}
void MainLoop::End()
} else if (input.GetKeyCount(KEY_INPUT_F1) == 1) {
inputbox_->Inactivate();
return BasePtr(new scene::Option(manager_accessor_, shared_from_this()));
+ } else if (input.GetKeyCount(KEY_INPUT_F2) == 1) {
+ inputbox_->Inactivate();
+ return BasePtr(new scene::Dashboard(manager_accessor_, shared_from_this()));
} else{
return nullptr;
}
if (input->GetKeyCount(KEY_INPUT_F1) == 1 ||
input->GetKeyCount(KEY_INPUT_ESCAPE) == 1 ||
- (!hover && input->GetMouseLeftCount() == 1)) {
+ (!hover && (input->GetMouseLeftCount() == 1 || input->GetMouseRightCount() == 1))) {
end_count_++;
}
const int InputBox::IME_MIN_WIDTH = 120;
InputBox::InputBox(const ManagerAccessorPtr& manager_accessor) :
- x_(100),
- y_(100),
- width_(800),
- height_(100),
multiline_(true),
font_height_(ResourceManager::default_font_size()),
drag_offset_x_(-1),
std::vector<std::string>(), false, false))
{
+ absolute_rect_ = Rect(100, 100, 800, 100);
+
font_handle_ = ResourceManager::default_font_handle();
bg_image_handle_ = ResourceManager::LoadCachedDivGraph<4>(
_T("resources/images/gui/gui_inputbox_bg.png"), 2, 2, 24, 24);
int screen_width, screen_height;
GetScreenState(&screen_width, &screen_height, nullptr);
- width_ = std::min(DEFAULT_MAX_WIDTH + 0, (int)(screen_width * 0.4));
- height_ = input_.height() + BOX_TOP_MARGIN + BOX_BOTTOM_MARGIN;
- x_ = (screen_width - width_) / 2;
- y_ = screen_height - height_ - BOX_BOTTOM_MARGIN;
+ absolute_rect_.width = std::min(DEFAULT_MAX_WIDTH + 0, (int)(screen_width * 0.4));
+ absolute_rect_.height = input_.height() + BOX_TOP_MARGIN + BOX_BOTTOM_MARGIN;
+ absolute_rect_.x = (screen_width - absolute_rect_.width) / 2;
+ absolute_rect_.y = screen_height - absolute_rect_.height - BOX_BOTTOM_MARGIN;
selecting_tab_index_ = 0;
{
int tab_index = 0;
- SetDrawArea(x_, script_tab_.y, script_tab_.x, script_tab_.y + script_tab_.height);
+ SetDrawArea(absolute_rect_.x, script_tab_.y, script_tab_.x, script_tab_.y + script_tab_.height);
BOOST_FOREACH(auto& tab, tabs_) {
std::array<ImageHandlePtr, 4>* image_handle;
TRUE);
SetDrawBlendMode(DX_BLENDMODE_ALPHA, 100);
- DrawStringToHandle(tab_x + 9, y_ + TAB_TOP_MARGIN + 1, unicode::ToTString(tab.name).c_str(),
+ DrawStringToHandle(tab_x + 9, absolute_rect_.y + TAB_TOP_MARGIN + 1, unicode::ToTString(tab.name).c_str(),
GetColor(255, 255, 255), font_handle_);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
- DrawStringToHandle(tab_x + 9, y_ + TAB_TOP_MARGIN, unicode::ToTString(tab.name).c_str(),
+ DrawStringToHandle(tab_x + 9, absolute_rect_.y + TAB_TOP_MARGIN, unicode::ToTString(tab.name).c_str(),
GetColor(0, 0, 0), font_handle_);
tab_index++;
SetDrawBright(255, 255, 255);
- DrawGraph(x_ + width_ - TAB_SIDE_MARGIN - 16, y_ + TAB_TOP_MARGIN,
+ DrawGraph(absolute_rect_.x + absolute_rect_.width - TAB_SIDE_MARGIN - 16, absolute_rect_.y + TAB_TOP_MARGIN,
*script_icon_image_handle_, TRUE);
}
}
SetDrawBlendMode(DX_BLENDMODE_ADD, 150);
}
- DrawGraph(x_, y_, *bg_image_handle_[0], TRUE);
- DrawGraph(x_ + width_ - 24, y_, *bg_image_handle_[1], TRUE);
- DrawGraph(x_, y_ + height_ - 24, *bg_image_handle_[2], TRUE);
- DrawGraph(x_ + width_ - 24, y_ + height_ - 24, *bg_image_handle_[3], TRUE);
+ DrawGraph(absolute_rect_.x, absolute_rect_.y, *bg_image_handle_[0], TRUE);
+ DrawGraph(absolute_rect_.x + absolute_rect_.width - 24, absolute_rect_.y, *bg_image_handle_[1], TRUE);
+ DrawGraph(absolute_rect_.x, absolute_rect_.y + absolute_rect_.height - 24, *bg_image_handle_[2], TRUE);
+ DrawGraph(absolute_rect_.x + absolute_rect_.width - 24, absolute_rect_.y + absolute_rect_.height - 24, *bg_image_handle_[3], TRUE);
- DrawRectExtendGraphF(x_ + 24, y_,
- x_ + width_ - 24, y_ + 24,
+ DrawRectExtendGraphF(absolute_rect_.x + 24, absolute_rect_.y,
+ absolute_rect_.x + absolute_rect_.width - 24, absolute_rect_.y + 24,
0, 0, 1, 24, *bg_image_handle_[1], TRUE);
- DrawRectExtendGraphF(x_ + 24, y_ + height_ - 24,
- x_ + width_ - 24, y_ + height_,
+ DrawRectExtendGraphF(absolute_rect_.x + 24, absolute_rect_.y + absolute_rect_.height - 24,
+ absolute_rect_.x + absolute_rect_.width - 24, absolute_rect_.y + absolute_rect_.height,
0, 0, 1, 24, *bg_image_handle_[3], TRUE);
- DrawRectExtendGraphF(x_, y_ + 24,
- x_ + 24, y_ + height_ - 24,
+ DrawRectExtendGraphF(absolute_rect_.x, absolute_rect_.y + 24,
+ absolute_rect_.x + 24, absolute_rect_.y + absolute_rect_.height - 24,
0, 0, 24, 1, *bg_image_handle_[2], TRUE);
- DrawRectExtendGraphF(x_ + width_ - 24, y_ + 24,
- x_ + width_, y_ + height_ - 24,
+ DrawRectExtendGraphF(absolute_rect_.x + absolute_rect_.width - 24, absolute_rect_.y + 24,
+ absolute_rect_.x + absolute_rect_.width, absolute_rect_.y + absolute_rect_.height - 24,
0, 0, 24, 1, *bg_image_handle_[3], TRUE);
- DrawRectExtendGraphF(x_ + 24, y_ + 24,
- x_ + width_ - 24, y_ + height_ - 24,
+ DrawRectExtendGraphF(absolute_rect_.x + 24, absolute_rect_.y + 24,
+ absolute_rect_.x + absolute_rect_.width - 24, absolute_rect_.y + absolute_rect_.height - 24,
0, 0, 1, 1, *bg_image_handle_[3], TRUE);
SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0);
int screen_height;
GetScreenState(nullptr, &screen_height, nullptr);
- if (y_ + height_ > screen_height - BOX_TOP_MARGIN) {
- y_ -= new_height - height_;
+ if (absolute_rect_.y + absolute_rect_.height > screen_height - BOX_TOP_MARGIN) {
+ absolute_rect_.y -= new_height - absolute_rect_.height;
// input_.set_y(y_ + BOX_TOP_MARGIN);
}
- height_ = new_height;
+ absolute_rect_.height = new_height;
- input_.set_y(y_ + BOX_TOP_MARGIN);
- input_.set_x(x_ + INPUT_MARGIN_X);
- input_.set_width(width_ - INPUT_MARGIN_X * 2);
+ input_.set_y(absolute_rect_.y + BOX_TOP_MARGIN);
+ input_.set_x(absolute_rect_.x + INPUT_MARGIN_X);
+ input_.set_width(absolute_rect_.width - INPUT_MARGIN_X * 2);
//line_buffer.clear();
//line_width = 0;
tab.card = card;
tab.name = unicode::ToTString(card->name());
- tab.x = x_ + TAB_SIDE_MARGIN + tab_offset_x - 9;
- tab.y = y_ - 3;
+ tab.x = absolute_rect_.x + TAB_SIDE_MARGIN + tab_offset_x - 9;
+ tab.y = absolute_rect_.y - 3;
tab.height = font_height_ + TAB_TOP_MARGIN * 2 + 3 * 2;
auto name = unicode::ToTString(tab.name);
// タブ選択
int tab_offset_x = 0;
BOOST_FOREACH(auto& tab, tabs_) {
- tab.x = x_ + TAB_SIDE_MARGIN + tab_offset_x - 9;
- tab.y = y_ - 3;
+ tab.x = absolute_rect_.x + TAB_SIDE_MARGIN + tab_offset_x - 9;
+ tab.y = absolute_rect_.y - 3;
tab.height = font_height_ + TAB_TOP_MARGIN * 2 + 3 * 2;
auto name = unicode::ToTString(tab.name);
tab_offset_x += tab.width - 3;
}
- script_tab_.x = x_ + width_ - TAB_SIDE_MARGIN - 16 - 9;
- script_tab_.y = y_ - 3;
+ script_tab_.x = absolute_rect_.x + absolute_rect_.width - TAB_SIDE_MARGIN - 16 - 9;
+ script_tab_.y = absolute_rect_.y - 3;
script_tab_.width = 16 + 18;
script_tab_.height = font_height_ + TAB_TOP_MARGIN * 2 + 3 * 2;
}
int screen_width, screen_height;
GetScreenState(&screen_width, &screen_height, nullptr);
- bool hover = (x_ <= input->GetMouseX() && input->GetMouseX() <= x_ + width_
- && y_ <= input->GetMouseY() && input->GetMouseY() <= y_ + height_);
+ bool hover = (absolute_rect_.x <= input->GetMouseX() && input->GetMouseX() <= absolute_rect_.x + absolute_rect_.width
+ && absolute_rect_.y <= input->GetMouseY() && input->GetMouseY() <= absolute_rect_.y + absolute_rect_.height);
//bool input_hover = (input_x_ <= input->GetMouseX()
// && input->GetMouseX() <= input_x_ + input_width_
// && input_y_ <= input->GetMouseY()
// && input->GetMouseY() <= input_y_ + input_height_);
- bool corner_hover = (x_ + width_ - 18 <= input->GetMouseX()
- && input->GetMouseX() <= x_ + width_
- && y_ + height_ - 18 <= input->GetMouseY()
- && input->GetMouseY() <= y_ + height_);
+ bool corner_hover = (absolute_rect_.x + absolute_rect_.width - 18 <= input->GetMouseX()
+ && input->GetMouseX() <= absolute_rect_.x + absolute_rect_.width
+ && absolute_rect_.y + absolute_rect_.height - 18 <= input->GetMouseY()
+ && input->GetMouseY() <= absolute_rect_.y + absolute_rect_.height);
// ドラッグ処理
if (input->GetMouseLeft()) {
if (input->GetPrevMouseLeft() == 0 && drag_offset_x_ < 0 && hover
&& !corner_hover) {
- drag_offset_x_ = input->GetMouseX() - x_;
- drag_offset_y_ = input->GetMouseY() - y_;
+ drag_offset_x_ = input->GetMouseX() - absolute_rect_.x;
+ drag_offset_y_ = input->GetMouseY() - absolute_rect_.y;
}
if (input->GetPrevMouseLeft() == 0 && drag_resize_offset_x_ < 0
&& corner_hover) {
- drag_resize_offset_x_ = x_ + width_ - input->GetMouseX();
- drag_resize_offset_y_ = y_ + height_ - input->GetMouseY();
+ drag_resize_offset_x_ = absolute_rect_.x + absolute_rect_.width - input->GetMouseX();
+ drag_resize_offset_y_ = absolute_rect_.y + absolute_rect_.height - input->GetMouseY();
}
if (hover && !IsActive()) {
Activate();
}
if (drag_offset_x_ >= 0) {
- x_ = input->GetMouseX() - drag_offset_x_;
- y_ = input->GetMouseY() - drag_offset_y_;
- x_ = std::max(0, x_); x_ = std::min(screen_width - width_, x_);
- y_ = std::max(0, y_); y_ = std::min(screen_height - height_, y_);
+ absolute_rect_.x = input->GetMouseX() - drag_offset_x_;
+ absolute_rect_.y = input->GetMouseY() - drag_offset_y_;
+ absolute_rect_.x = std::max(0, absolute_rect_.x); absolute_rect_.x = std::min(screen_width - absolute_rect_.width, absolute_rect_.x);
+ absolute_rect_.y = std::max(0, absolute_rect_.y); absolute_rect_.y = std::min(screen_height - absolute_rect_.height, absolute_rect_.y);
input->CancelMouseLeft();
} else if (drag_resize_offset_x_ >= 0) {
- int new_width = input->GetMouseX() - x_ + drag_resize_offset_x_;
+ int new_width = input->GetMouseX() - absolute_rect_.x + drag_resize_offset_x_;
new_width = std::max(new_width, (BOX_MIN_WIDTH + 0));
- new_width = std::min(new_width, screen_width - x_);
- width_ = new_width;
+ new_width = std::min(new_width, screen_width - absolute_rect_.x);
+ absolute_rect_.width = new_width;
input->CancelMouseLeft();
}
}
void SetScriptMode();
private:
- int x_, y_, width_, height_;
int multiline_;
private:
int UISuper::focus_index() const
{
return focus_index_;
+}
+
+ImageHandlePtr UISuper::icon_image_handle() const
+{
+ return icon_image_handle_;
+}
+
+void UISuper::set_icon_image_handle(const ImageHandlePtr& handle)
+{
+ icon_image_handle_ = handle;
}
\ No newline at end of file
#include <string>
#include <iostream>
#include <vector>
+#include "../ResourceManager.hpp"
class InputManager;
int focus_index() const;
+ ImageHandlePtr icon_image_handle() const;
+ void set_icon_image_handle(const ImageHandlePtr& handle);
+
enum {
DOCKING_NONE = 0,
DOCKING_TOP = 1,
bool visible_;
std::string base_image_;
-
+ ImageHandlePtr icon_image_handle_;
};
typedef std::shared_ptr<UISuper> UISuperPtr;
#define MMO_VERSION_MAJOR 0
#define MMO_VERSION_MINOR 3
-#define MMO_VERSION_REVISION 10
+#define MMO_VERSION_REVISION 11
#define MMO_PROTOCOL_VERSION 2