void PindianBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
    QString title = QString("%1: %2").arg(tr("pindian")).arg(Sanguosha->translate(reason));
    GraphicsBox::paintGraphicsBoxStyle(painter, title, boundingRect());

    const int card_width = G_COMMON_LAYOUT.m_cardNormalWidth;
    const int card_height = G_COMMON_LAYOUT.m_cardNormalHeight;

    int first = (width - targets.length() * card_width - (targets.length() - 1) * (cardInterval + 20)) / 2;

    for (int i = 0; i < targets.length(); ++i) {
        int x, y = 0;
        x = (first + (card_width + cardInterval + 20) * i);
        y = (45);

        QString description1 = ClientInstance->getPlayerName(targets.at(i));
        QRect up_rect(x - cardInterval / 2 - 20, 45, 20, card_height);
        G_COMMON_LAYOUT.playerCardBoxPlaceNameText.paintText(painter, up_rect, Qt::AlignCenter, description1);

        QRect top_rect(x, y, card_width, card_height);
        painter->drawPixmap(top_rect, G_ROOM_SKIN.getPixmap(QSanRoomSkin::S_SKIN_KEY_CHOOSE_GENERAL_BOX_DEST_SEAT));
        IQSanComponentSkin::QSanSimpleTextFont font = G_COMMON_LAYOUT.m_chooseGeneralBoxDestSeatFont;
        font.paintText(painter, top_rect, Qt::AlignCenter, ClientInstance->getPlayerName(targets.at(i)));
    }

    QString description2 = tr("requestor");
    QRect down_rect((width - card_width) / 2 - cardInterval / 2 - 20, 45 + (card_height + cardInterval), 20, card_height);
    QRect down_rect2((width - card_width) / 2 - cardInterval - 40, 45 + (card_height + cardInterval), 20, card_height);
    G_COMMON_LAYOUT.playerCardBoxPlaceNameText.paintText(painter, down_rect, Qt::AlignCenter, ClientInstance->getPlayerName(zhuge));
    G_COMMON_LAYOUT.playerCardBoxPlaceNameText.paintText(painter, down_rect2, Qt::AlignCenter, description2);

    QRect bottom_rect((width - card_width) / 2, 45 + card_height + cardInterval, card_width, card_height);
    painter->drawPixmap(bottom_rect, G_ROOM_SKIN.getPixmap(QSanRoomSkin::S_SKIN_KEY_CHOOSE_GENERAL_BOX_DEST_SEAT));
    IQSanComponentSkin::QSanSimpleTextFont font = G_COMMON_LAYOUT.m_chooseGeneralBoxDestSeatFont;
    font.paintText(painter, bottom_rect, Qt::AlignCenter, ClientInstance->getPlayerName(zhuge));
}
示例#2
0
	MainWindow::MainWindow(const ax::Rect& rect, const std::string& proj_path)
		: _font(0)
		, _view_handler(this)
		, _widget_handler(this)
		, _project_handler(this)
	{
		// Create window.
		win = ax::Window::Create(rect);
		win->event.OnPaint = ax::WBind<ax::GC>(this, &MainWindow::OnPaint);
		win->event.OnPaintOverChildren = ax::WBind<ax::GC>(this, &MainWindow::OnPaintOverChildren);
		win->event.OnResize = ax::WBind<ax::Size>(&_view_handler, &MainWindowViewHandler::OnResize);
		win->event.OnKeyDown = ax::WBind<char>(this, &MainWindow::OnGlobalKey);
		win->event.OnAssignToWindowManager = ax::WBind<int>(this, &MainWindow::OnAssignToWindowManager);

		win->AddConnection(999, GetOnHelpBar());

		_font.SetFontSize(10);

		// Create top menu.
		ax::Rect top_menu_rect(0, 0, rect.size.w, STATUS_BAR_HEIGHT);
		_statusBar = new StatusBar(top_menu_rect);
		win->node.Add(std::shared_ptr<ax::Window::Backbone>(_statusBar));

		if (!proj_path.empty()) {
			_project.Open(proj_path);
			_statusBar->SetLayoutFilePath(_project.GetLayoutPath());
		}
		else {
			_statusBar->SetLayoutFilePath("default.xml");
		}

		ax::Window* sb_win = _statusBar->GetWindow();
		sb_win->AddConnection(StatusBar::SAVE_LAYOUT, _project_handler.GetOnSaveProject());
		sb_win->AddConnection(StatusBar::SAVE_AS_LAYOUT, _project_handler.GetOnSaveAsProject());
		sb_win->AddConnection(StatusBar::OPEN_LAYOUT, _project_handler.GetOnOpenProject());
		sb_win->AddConnection(StatusBar::CREATE_NEW_LAYOUT, _project_handler.GetOnCreateNewProject());

		sb_win->AddConnection(StatusBar::RELOAD_SCRIPT, GetOnReloadScript());
		sb_win->AddConnection(StatusBar::STOP_SCRIPT, GetOnStopScript());

		sb_win->AddConnection(StatusBar::TOGGLE_LEFT_PANEL, _view_handler.GetOnToggleLeftPanel());
		sb_win->AddConnection(StatusBar::TOGGLE_BOTTOM_PANEL, _view_handler.GetOnToggleBottomPanel());
		sb_win->AddConnection(StatusBar::TOGGLE_RIGHT_PANEL, _view_handler.GetOnToggleRightPanel());

		sb_win->AddConnection(StatusBar::VIEW_LAYOUT, _view_handler.GetOnViewLayout());

		// Events from MainWindow to status bar.
		win->AddConnection(HAS_WIDGET_ON_GRID, _statusBar->GetOnHasWidgetOnGrid());

		// Create grid window.
		ax::Rect grid_rect(WIDGET_MENU_WIDTH, STATUS_BAR_HEIGHT,
			rect.size.w - WIDGET_MENU_WIDTH - INSPECTOR_MENU_WIDTH,
			rect.size.h - STATUS_BAR_HEIGHT - 200 - BOTTOM_BAR_HEIGHT);
		win->node.Add(_gridWindow = ax::shared<GridWindow>(grid_rect));

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SELECT_WIDGET, _widget_handler.GetOnSelectWidget());
		_gridWindow->GetWindow()->AddConnection(
			GridWindow::UNSELECT_ALL, _widget_handler.GetOnUnSelectAllWidget());
		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SAVE_PANEL_TO_WORKSPACE, GetOnSavePanelToWorkspace());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DELETE_SELECTED_WIDGET, _widget_handler.GetOnDeleteSelectedWidget());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DUPLICATE_SELECTED_WIDGET, _widget_handler.GetOnDuplicateSelectedWidget());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DELETE_SELECTED_WIDGET_FROM_RIGHT_CLICK, GetOnRemoveWidgetFromRightClickMenu());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DUPLICATE_SELECTED_WIDGET_FROM_RIGHT_CLICK, GetOnDuplicateWidgetFromRightClickMenu());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SNAP_WIDGET_TO_GRID_FROM_RIGHT_CLICK, GetOnSnapToGridWidgetFromRightClickMenu());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SELECT_MULTIPLE_WIDGET, _widget_handler.GetOnSelectMultipleWidget());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::ARROW_MOVE_SELECTED_WIDGET, _widget_handler.GetOnArrowMoveSelectedWidget());

		if (!proj_path.empty()) {
			_gridWindow->OpenLayout(_project.GetLayoutPath());
		}
		else {
			_gridWindow->OpenLayout("layouts/default.xml");
		}

		// Create widget menu.
		ax::Rect widget_menu_rect(
			0, STATUS_BAR_HEIGHT, WIDGET_MENU_WIDTH, rect.size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT);

		auto l_side_menu = ax::shared<LeftSideMenu>(widget_menu_rect);
		win->node.Add(l_side_menu);
		_left_menu = l_side_menu.get();

		l_side_menu->GetWindow()->AddConnection(
			WidgetMenu::SMALLER_MENU, _view_handler.GetOnSmallerLeftMenu());

		// Create info menu.
		ax::Rect info_rect(rect.size.w - INSPECTOR_MENU_WIDTH, STATUS_BAR_HEIGHT, INSPECTOR_MENU_WIDTH,
			rect.size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT);

		auto right_menu = ax::shared<RightSideMenu>(info_rect);
		win->node.Add(right_menu);
		_right_menu = right_menu.get();

		// Create code editor.
		TextEditor::Info txt_info;
		txt_info.bg_color = ax::Color(1.0);
		txt_info.cursor_color = ax::Color(0.0);
		txt_info.line_number_bg_color = ax::Color(0.95);
		txt_info.line_number_color = ax::Color(0.4);
		txt_info.text_color = ax::Color(0.0);

		ax::Rect bottom_rect(WIDGET_MENU_WIDTH + 1, rect.size.h - 200 - BOTTOM_BAR_HEIGHT,
			rect.size.w - WIDGET_MENU_WIDTH - INSPECTOR_MENU_WIDTH, 200);

		std::string script_path;

		if (!proj_path.empty()) {
			script_path = _project.GetScriptPath();
		}
		else {
			script_path = "scripts/default.py";
		}

		auto b_section = ax::shared<BottomSection>(bottom_rect, script_path);
		win->node.Add(b_section);
		_bottom_section = b_section.get();
		_bottom_section->GetWindow()->AddConnection(
			BottomSection::RESIZE, _view_handler.GetOnResizeCodeEditor());

		_bottom_section->GetWindow()->AddConnection(10020, ax::event::Function([&](ax::event::Msg* msg) {
			ax::console::Print("Save");
			std::vector<std::shared_ptr<ax::Window>>& children = _gridWindow->GetWindow()->node.GetChildren();

			for (auto& n : children) {
				n->Update();
			}
		}));

		win->AddConnection(global::CREATE_DRAGGING_WIDGET, _widget_handler.GetOnCreateDraggingWidget());
		win->AddConnection(global::DRAGGING_WIDGET, _widget_handler.GetOnDraggingWidget());
		win->AddConnection(global::RELEASE_WIDGET, _widget_handler.GetOnReleaseObjWidget());
		win->AddConnection(
			global::CREATE_CUSTOM_DRAGGING_WIDGET, _widget_handler.GetOnCreateCustomDraggingWidget());

		// Midi feedback.
		auto midi_feedback = ax::shared<at::MidiFeedback>(
			ax::Rect(ax::Point(rect.size.w - 17, rect.size.h - 15), ax::Size(10, 10)));
		_midi_feedback = midi_feedback.get();

		win->node.Add(midi_feedback);
	}