Beispiel #1
0
int Window_( lua_State* L )
{
  UIWindow* window = new UIWindow;

  SetName(L, window);
  SetTopLeftWidthHeight(L, window);
  SetTooltip(L, window);
  SetAnim(L, window, UIPanel::NORMAL_ANIM_, "normalAnim");
  SetAnim(L, window, UIPanel::DISABLED_ANIM_, "disabledAnim");
  SetTextUserData(L, window);

  AddWidget(L, window);

  // 配置关闭按钮

  if (util::HasField(L, "closeBtn"))
  {
    lua_pushstring(L, "closeBtn");
    lua_gettable(L, -2);
    if (lua_istable(L, -1))
      SetButton(L, window->GetCloseButton());
    lua_pop(L, 1);
  }

  SetAlpha(L, window);

  lua_pushlightuserdata(L, window);

  return 1;
}
Beispiel #2
0
void UI::render ()
{
	std::vector<UIWindow*> renderOrder;
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		renderOrder.push_back(window);
		// we can skip here
		if (window->isFullscreen())
			break;
	}

	for (std::vector<UIWindow*>::reverse_iterator i = renderOrder.rbegin(); i != renderOrder.rend(); ++i) {
		(*i)->render(0, 0);
	}

	// TODO: move cursor and progress bar into frontend
	if (_progress.active) {
		renderProgress();
	}

	if (_cursorX != -1 && _cursorY != -1 && _cursor) {
		const int w = _mouseCursor->getWidth();
		const int h = _mouseCursor->getHeight();
		_frontend->renderImage(_mouseCursor.get(), _cursorX, _cursorY, w, h, 0, 1.0f);
	}

	const bool debug = Config.getConfigVar("debugui")->getBoolValue();
	if (debug) {
		const BitmapFontPtr& font = getFont();
		const std::string s = String::format("%i:%i", _cursorX, _cursorY);
		font->print(s, colorWhite, 0, 0);
	}
}
bool LayoutManager::ProcessPointer(float x, float y, float z, Msg msg, int button, PointerType pointerType, unsigned int pointerID)
{
#ifndef NDEBUG
    _lastPointerLocation[pointerID] = Vector2(x, y);
#endif

	if(UIWindow *captured = GetCapture(pointerID) )
	{
		// calc relative mouse position and route message to captured window
		for(UIWindow *wnd = captured; _desktop.Get() != wnd; wnd = wnd->GetParent() )
		{
			assert(wnd);
			x -= wnd->GetX();
			y -= wnd->GetY();
		}
		if( ProcessPointerInternal(captured, x, y, z, msg, button, pointerType, pointerID, true) ||
            ProcessPointerInternal(captured, x, y, z, msg, button, pointerType, pointerID, false))
			return true;
	}
	else
	{
		// handle all children of the desktop recursively; offer to topmost windows first
		if( ProcessPointerInternal(_desktop.Get(), x, y, z, msg, button, pointerType, pointerID, true) ||
            ProcessPointerInternal(_desktop.Get(), x, y, z, msg, button, pointerType, pointerID, false))
			return true;
	}
	if( _hotTrackWnd.Get() )
	{
		_hotTrackWnd->OnMouseLeave();
		_hotTrackWnd.Set(nullptr);
	}
	return false;
}
Beispiel #4
0
int main(int argc, char *argv[])
{
    cout<<"Under Construction ... "<<endl<<"Hello"<<argc<<endl;
    QApplication app(argc, argv);
    UIWindow window;
    window.show();
    return app.exec();
}
Beispiel #5
0
void UICanvas::showMessageBox(const String& message)
{
	Widget* modalBackground = new Widget();
	
	UIWindow* surface = addSurface("modal");
	surface->attach(modalBackground);
	modalBackground->setRect(surface->getRect());

	UILabel* label = new UILabel(message);
	label->setSize(700,50);
	//label->setCenter(modalBackground->getMiddlePosition());
	modalBackground->attach(label);
};
Beispiel #6
0
void UI::onMouseButtonPress (int32_t x, int32_t y, uint8_t button)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onMouseButtonPress(_cursorX, _cursorY, button))
			break;
		if (window->isModal() || window->isFullscreen())
			break;
	}
}
Beispiel #7
0
void UIButtonGroup::SetFocusedIndex(int index)
{
    if (index >=0 && (unsigned int)index < GetChildrenCount())
    {
        m_currentFocusedIndex = index;
#ifndef KINDLE_FOR_TOUCH
        UIWindow* pWin = GetChildByIndex(index);
        if (pWin)
        {
            pWin->SetFocus(true);
        }
#endif
    }
}
Beispiel #8
0
HRESULT UIButtonGroup::Draw(DK_IMAGE drawingImg)
{
    if (!m_bIsVisible)
        return S_OK;
    
    HRESULT hr(S_OK);
    DK_IMAGE imgSelf;
    int left = m_iLeft, top = m_iTop, right = m_iLeft + m_iWidth, bottom = m_iTop + m_iHeight;
    DK_RECT rcSelf={left, top, right, bottom};
    RTN_HR_IF_FAILED(CropImage(
        drawingImg,
        rcSelf,
        &imgSelf
        ));
    CTpGraphics grf(imgSelf);
    ValidChildBtnShown();
    int iSize = GetChildrenCount();
    for (int i = 0; i < iSize; i++)
    {
        UIWindow* pWin = GetChildByIndex(i);
        if (pWin && pWin->IsVisible())
        {
            DebugPrintf(DLC_GUI_VERBOSE,
                    "%s: Drawing Child %d / %d : %s, (%d, %d)-(%d, %d), %s ...",
                    GetClassName(), i, iSize, pWin->GetClassName(),
                    pWin->GetX(), pWin->GetY(),
                    pWin->GetWidth(), pWin->GetHeight(),
                    pWin->GetText());
            hr = pWin->Draw(imgSelf);
            if (!SUCCEEDED(hr))
            {
                DebugPrintf(DLC_GUI_VERBOSE, "Draw child failed");
            }
        }
        else
        {
            DebugPrintf(DLC_ERROR, "%s: FAILED to get child %d/%d !!!", GetClassName(), i, iSize);
        }
    }

    if (m_btnsDirection == BGD_Horizontal)
    {
        DrawTopLine(grf);
        DrawBottomLine(grf);
    }
    DrawSplitLine(grf);

    if (m_currentFocusedIndex >= 0 && (unsigned int)m_currentFocusedIndex < GetChildrenCount())
    {
        DrawFocusedSymbol(imgSelf);
    }

    return hr;
}
Beispiel #9
0
void UI::onGestureRecord (int64_t gestureId)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onGestureRecord(gestureId))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "gesture record event was not handled");
}
Beispiel #10
0
void UI::onControllerButtonPress (const std::string& button)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onControllerButtonPress(_cursorX, _cursorY, button))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "controller button " + button + " was pressed and not handled");
}
Beispiel #11
0
void UI::onGesture (int64_t gestureId, float error, int32_t numFingers)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onGesture(gestureId, error, numFingers))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "gesture event was not handled");
}
Beispiel #12
0
void UI::onJoystickButtonPress (uint8_t button)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onJoystickButtonPress(_cursorX, _cursorY, button))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, String::format("joystick button %i was pressed and not handled", (int)button));
}
Beispiel #13
0
bool UI::onTextInput (const std::string& text)
{
	if (_restart)
		return false;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onTextInput(text))
			return true;
		if (window->isModal() || window->isFullscreen())
			break;
	}
	return false;
}
Beispiel #14
0
void UI::onMultiGesture (float theta, float dist, int32_t numFingers)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onMultiGesture(theta, dist, numFingers))
			return;
		if (window->isModal() || window->isFullscreen())
			return;
	}
	debug(LOG_CLIENT, "multi gesture event was not handled");
}
Beispiel #15
0
void UI::onMouseWheel (int32_t x, int32_t y)
{
	if (_restart)
		return;

	GETSCALE_W(x);
	GETSCALE_H(y);
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onMouseWheel(x, y))
			break;
		if (window->isModal() || window->isFullscreen())
			break;
	}
}
Beispiel #16
0
/**
* 隐藏Panel
*/
int UILib::hidepanel(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIWindow *window = stub->base->getDepthWindow();
		if (window)
		{
			UIPanel *target = window->getPanel(node->getAttr("name"));
			if (target)
			{
				target->hide();
			}
		}
	}
	return 1;
}
Beispiel #17
0
bool UI::onKeyPress (int32_t key, int16_t modifier)
{
	if (_restart)
		return false;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onKeyPress(key, modifier))
			return true;
		if (window->isModal() || window->isFullscreen())
			break;
	}

	return false;
}
void CreatureManager::UnSelectCreature()
{
	if (m_nSelectNum >= 0)
	{
		int nLastSelect = m_nSelectNum;
		if (g_getRButtonState(App::sInstance().GetHGE()) == eRButtonState_Up)
		{
			Character* lastChar = GetCreature(nLastSelect);
			if(lastChar!=NULL && lastChar->GetCamp()==eCamp_Friend && !(lastChar->GetFinish()))
			{
				//返回至原位置
				eActionStage stage = lastChar->GetActionStage();
				if(stage == eActionStage_HandleStage)
				{
					lastChar->SetActionStage(eActionStage_MoveStage);
					lastChar->CancelMove();
					//关闭操作界面
					UIWindow* commandWindow = UISystem::sInstance().GetWindow(eWindowID_Command);
					if(commandWindow)
					{
						commandWindow->SetShow(false);
					}
				}
				//攻击阶段、技能阶段、使用物品阶段可以返回至操作阶段
				else if(stage == eActionStage_AttackStage || stage == eActionStage_GoodStage || stage == eActionStage_SkillStage)
				{
					lastChar->SetActionStage(eActionStage_HandleStage);
					//打开操作界面
					UIWindow* commandWindow = UISystem::sInstance().GetWindow(eWindowID_Command);
					if(commandWindow)
					{
						commandWindow->SetShow(true);
						commandWindow->SetBindChar(lastChar);
					}
				}
				//右键取消选中的友方,需要重置行动阶段,处于移动中的单位不可以当时取消
				else if(stage == eActionStage_MoveStage && lastChar->GetCharacterState()==eCharacterState_Stand)	
				{
					lastChar->SetActionStage(eActionStage_WaitStage);
					m_nSelectNum = -1;
				}
			}
			else
				m_nSelectNum = -1;
		}
	}
}
Beispiel #19
0
bool UI::onFingerPress (int64_t finger, float x, float y)
{
	if (_restart)
		return false;

	const uint16_t _x = _frontend->getCoordinateOffsetX() + x * _frontend->getWidth();
	const uint16_t _y = _frontend->getCoordinateOffsetY() + y * _frontend->getHeight();
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onFingerPress(finger, _x, _y))
			return true;
		if (window->isModal() || window->isFullscreen())
			break;
	}
	return false;
}
Beispiel #20
0
/**
 * 绑定自身panel 的处理逻辑 C++ 写的逻辑
 */
int UILib::panelbind(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIPanel *panel = stub->base->getPanel();
		if (panel)
		{
			UIWindow *window = panel->getWindow();
			if (window)
			{
				UIPanel *target = window->getPanel(node->getAttr("name"));
				if (target)
					target->bindBtnClick(node->getAttr("btnname"),UICALLBACK(node->getAttr("event")));
			}	
		}
	}
	return 1;
}
Beispiel #21
0
void UI::pushRoot (const std::string& windowID)
{
	_noPushAllowed = true;
	while (!_stack.empty()) {
		UIWindow* window = *_stack.rbegin();
		window->onPop();
		_stack.pop_back();
		if (!_stack.empty()) {
			_stack.back()->onActive();
		}

		if (window->shouldDelete()) {
			delete window;
		}
	}
	_noPushAllowed = false;
	push(windowID);
}
Beispiel #22
0
void UI::onFingerMotion (int64_t finger, float x, float y, float dx, float dy)
{
	if (_restart)
		return;

	const uint16_t _x = _frontend->getCoordinateOffsetX() + x * _frontend->getWidth();
	const uint16_t _y = _frontend->getCoordinateOffsetY() + y * _frontend->getHeight();
	const int16_t _dx = dx * _frontend->getWidth();
	const int16_t _dy = dy * _frontend->getHeight();
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onFingerMotion(finger, _x, _y, _dx, _dy))
			break;
		if (window->isModal() || window->isFullscreen())
			break;
	}
}
Beispiel #23
0
/**
* 展示panel 
*/
int UILib::showpanel(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIWindow *window = stub->base->getDepthWindow();
		if (window)
		{
			UIPanel *panel = window->showPanel(node->getAttr("name"));
			std::string tag = node->getAttr("model");
			if (tag == "true" && panel)
			{
				window->pushModel(panel);
			}
			if (panel)
			panel->setVisible(true);
		}
	}
	return 1;
}
Beispiel #24
0
void UI::popMain ()
{
	_noPushAllowed = true;
	// don't pop the root window
	while (_stack.size() > 1) {
		UIWindow* window = *_stack.rbegin();
		if (window->isMain())
			break;
		info(LOG_CLIENT, "pop window " + window->getId());
		window->onPop();
		_stack.pop_back();
		_stack.back()->onActive();

		if (window->shouldDelete()) {
			delete window;
		}
	}
	_noPushAllowed = false;
}
Beispiel #25
0
bool LayoutManager::SetFocusWnd(UIWindow* wnd)
{
	assert(!_dbgFocusIsChanging);
	if( _focusWnd.Get() != wnd )
	{
		WindowWeakPtr wp(wnd);
		WindowWeakPtr oldFocusWnd(_focusWnd.Get());

		// try setting new focus. it should not change _focusWnd
#ifndef NDEBUG
		_dbgFocusIsChanging = true;
#endif
		bool focusAccepted = wnd && wnd->GetEnabledCombined() && wnd->GetVisibleCombined() && wnd->OnFocus(true);
#ifndef NDEBUG
		_dbgFocusIsChanging = false;
#endif
		if( !focusAccepted && wp.Get() && oldFocusWnd.Get() )
		{
			for(UIWindow *w = wp.Get()->GetParent(); w; w = w->GetParent() )
			{
				if( w == oldFocusWnd.Get() )
				{
					// don't reset focus from parent
					return false;
				}
			}
		}

		// set new focus
		_focusWnd.Set(focusAccepted ? wp.Get() : nullptr);
		assert(!_focusWnd.Get() || _focusWnd->GetEnabledCombined() && _focusWnd->GetVisibleCombined());

		// reset old focus
		if( oldFocusWnd.Get() && oldFocusWnd.Get() != _focusWnd.Get() )
		{
			oldFocusWnd->OnFocus(false); // _focusWnd may be destroyed here
			if( oldFocusWnd.Get() && oldFocusWnd->eventLostFocus )
				oldFocusWnd->eventLostFocus();
		}
	}
	return nullptr != _focusWnd.Get();
}
Beispiel #26
0
void UI::onJoystickMotion (bool horizontal, int v)
{
	if (_restart)
		return;

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		if (window->onJoystickMotion(horizontal, v))
			return;
		if (window->isModal() || window->isFullscreen())
			break;
	}

	if (Config.getBindingsSpace() != BINDINGS_UI)
		return;

	if (_time - _lastJoystickMoveTime < 350 || horizontal) {
		_lastJoystickMovementValue = v;
		return;
	}

	// skip focus change if we go back to initial position
	if (v > 0 && v < _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	} else if (v < 0 && v > _lastJoystickMovementValue) {
		_lastJoystickMovementValue = v;
		return;
	}

	// now check whether our value is bigger than our movement delta
	const int delta = 2000;
	if (v < -delta) {
		focusPrev();
	} else if (v > delta) {
		focusNext();
	}

	_lastJoystickMoveTime = _time;
	_lastJoystickMovementValue = v;
}
Beispiel #27
0
/**
 * 设置panel 上UILabel 的值
 */
int UILib::panel_label_set_value(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIPanel *panel = stub->base->getPanel();
		if (panel)
		{
			UIWindow *window = panel->getWindow();
			if (window)
			{
				UIPanel *target = window->getPanel(node->getAttr("name"));
				if (target)
				{
					target->setUILabelvalue(node->getAttr("labelname"),node->getAttr("value"));
				}
			}	
		}
	}
	return 1;
}
Beispiel #28
0
/**
 * 展示所有文件
 */
int UILib::files_show(UIStub* stub,script::tixmlCodeNode * node)
{
	if (stub && stub->base)
	{
		UIWindow *window = stub->base->getDepthWindow();
		if (window)
		{
			UIFileList *list = UIFileList::create(window,node->getAttr("showxml"));
			if (list)
			{
				std::string dirShowName = node->getAttr("dirshow");
				std::string fileShowName = node->getAttr("fileshow");
				list->showes.push_back(node->getAttr("showfile"));
				list->show(".","list",dirShowName.c_str(),fileShowName.c_str());
				window->pushModel(list);
			}
		}
	}
	return 1;
}
Beispiel #29
0
void UI::update (uint32_t deltaTime)
{
	_time += deltaTime;
	if (_delayedPop) {
		_delayedPop = false;
		pop();
	}
	if (_restart)
		restart();

	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		window->update(deltaTime);
	}

	for (Fonts::iterator i = _fonts.begin(); i != _fonts.end(); ++i) {
		i->second->update(deltaTime);
	}
}
Beispiel #30
0
void UI::onMouseMotion (int32_t x, int32_t y, int32_t relX, int32_t relY)
{
	if (_restart)
		return;

	GETSCALE_W(relX);
	GETSCALE_H(relY);
	_frontend->setCursorPosition(_cursorX + relX, _cursorY + relY);
	UIStack stack = _stack;
	for (UIStackReverseIter i = stack.rbegin(); i != stack.rend(); ++i) {
		UIWindow* window = *i;
		const bool focus = window->checkFocus(_cursorX, _cursorY);
		if (focus) {
			window->onMouseMotion(_cursorX, _cursorY, relX, relY);
			break;
		}
		if (window->isModal() || window->isFullscreen())
			break;
	}
}