当前位置: 首页>>代码示例>>Golang>>正文


Golang Gui.FocusWidget方法代码示例

本文整理汇总了Golang中github.com/runningwild/glop/gui.Gui.FocusWidget方法的典型用法代码示例。如果您正苦于以下问题:Golang Gui.FocusWidget方法的具体用法?Golang Gui.FocusWidget怎么用?Golang Gui.FocusWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/runningwild/glop/gui.Gui的用法示例。


在下文中一共展示了Gui.FocusWidget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Think

func (gp *GamePanel) Think(ui *gui.Gui, t int64) {
	gp.scriptThinkOnce()
	gp.AnchorBox.Think(ui, t)
	if !gp.Active() {
		return
	}
	if gp.game != nil {
		gp.game.modal = (ui.FocusWidget() != nil)
	}

	if gp.last_think == 0 {
		gp.last_think = t
	}
	dt := t - gp.last_think
	gp.last_think = t
	gp.game.Think(dt)

	if gp.main_bar != nil {
		if gp.game.selected_ent != nil {
			gp.main_bar.SelectEnt(gp.game.selected_ent)
		} else {
			gp.main_bar.SelectEnt(gp.game.hovered_ent)
		}
	}
}
开发者ID:RickDakan,项目名称:haunts,代码行数:25,代码来源:game.go

示例2: Respond

func (m *MainBar) Respond(g *gui.Gui, group gui.EventGroup) bool {
	if g.FocusWidget() != nil {
		return false
	}
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		m.mx, m.my = cursor.Point()
		if m.my > m.layout.Background.Data().Dy() {
			return false
		}
	}

	buttons := m.no_actions_buttons
	if m.ent != nil && len(m.ent.Actions) > m.layout.Actions.Count {
		buttons = m.all_buttons
	}
	for _, button := range buttons {
		if button.Respond(group, m) {
			return true
		}
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for _, button := range buttons {
			if button.handleClick(m.mx, m.my, m) {
				return true
			}
		}
		if m.ent != nil {
			index := m.pointInsideAction(m.mx, m.my)
			if index != -1 {
				m.state.Actions.clicked = m.ent.Actions[index]
			}
		}
	}

	if found, event := group.FindEvent(gin.MouseWheelVertical); found {
		x := int(m.layout.Conditions.X)
		y := int(m.layout.Conditions.Y)
		x2 := int(m.layout.Conditions.X + m.layout.Conditions.Width)
		y2 := int(m.layout.Conditions.Y + m.layout.Conditions.Height)
		if m.mx >= x && m.my >= y && m.mx < x2 && m.my < y2 {
			m.state.Conditions.scroll_pos += event.Key.FramePressAmt()
		}
	}

	return cursor != nil
}
开发者ID:RickDakan,项目名称:haunts,代码行数:48,代码来源:ui_main_bar.go

示例3: Think

func (hdt *houseRelicsTab) Think(ui *gui.Gui, t int64) {
	defer hdt.VerticalTable.Think(ui, t)
	rbx, rby := hdt.viewer.WindowToBoard(gin.In().GetCursor("Mouse").Point())
	bx := roundDown(rbx - hdt.drag_anchor.x + 0.5)
	by := roundDown(rby - hdt.drag_anchor.y + 0.5)
	if hdt.temp_relic != nil {
		hdt.temp_relic.X = bx
		hdt.temp_relic.Y = by
		hdt.temp_relic.Dx += gin.In().GetKey(gin.Right).FramePressCount()
		hdt.temp_relic.Dx -= gin.In().GetKey(gin.Left).FramePressCount()
		if hdt.temp_relic.Dx < 1 {
			hdt.temp_relic.Dx = 1
		}
		if hdt.temp_relic.Dx > 10 {
			hdt.temp_relic.Dx = 10
		}
		hdt.temp_relic.Dy += gin.In().GetKey(gin.Up).FramePressCount()
		hdt.temp_relic.Dy -= gin.In().GetKey(gin.Down).FramePressCount()
		if hdt.temp_relic.Dy < 1 {
			hdt.temp_relic.Dy = 1
		}
		if hdt.temp_relic.Dy > 10 {
			hdt.temp_relic.Dy = 10
		}
		hdt.markTempSpawnValidity()
	} else {
		_, _, spawn_at := hdt.house.Floors[0].RoomFurnSpawnAtPos(roundDown(rbx), roundDown(rby))
		if spawn_at != nil {
			hdt.spawn_name.SetText(spawn_at.Name)
		} else if hdt.spawn_name.IsBeingEdited() {
			hdt.typed_name = hdt.spawn_name.GetText()
		} else {
			hdt.spawn_name.SetText(hdt.typed_name)
		}
	}

	if hdt.temp_relic == nil && gin.In().GetKey('n').FramePressCount() > 0 && ui.FocusWidget() == nil {
		hdt.newSpawn()
	}
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:40,代码来源:house.go

示例4: Think

func (m *MainBar) Think(g *gui.Gui, t int64) {
	if g.FocusWidget() != nil {
		return
	}
	if m.ent != nil {
		// If an action is selected and we can't see it then we scroll just enough
		// so that we can.
		min := 0.0
		max := float64(len(m.ent.Actions) - m.layout.Actions.Count)
		selected_index := -1
		for i := range m.ent.Actions {
			if m.ent.Actions[i] == m.state.Actions.selected {
				selected_index = i
				break
			}
		}
		if selected_index != -1 {
			if min < float64(selected_index-m.layout.Actions.Count+1) {
				min = float64(selected_index - m.layout.Actions.Count + 1)
			}
			if max > float64(selected_index) {
				max = float64(selected_index)
			}
		}
		m.state.Actions.selected = m.game.current_action
		if m.state.Actions.scroll_target > max {
			m.state.Actions.scroll_target = max
		}
		if m.state.Actions.scroll_target < min {
			m.state.Actions.scroll_target = min
		}

		if m.state.Actions.clicked != nil {
			if m.state.Actions.selected != m.state.Actions.clicked {
				if m.state.Actions.clicked.Preppable(m.ent, m.game) {
					m.state.Actions.clicked.Prep(m.ent, m.game)
					m.game.SetCurrentAction(m.state.Actions.clicked)
				}
			}
			m.state.Actions.clicked = nil
		}

		// We similarly need to scroll through conditions
		c := m.layout.Conditions
		d := base.GetDictionary(int(c.Size))
		max_scroll := d.MaxHeight() * float64(len(m.ent.Stats.ConditionNames()))
		max_scroll -= m.layout.Conditions.Height
		// This might end up with a max that is negative, but we'll cap it at zero
		if m.state.Conditions.scroll_pos > max_scroll {
			m.state.Conditions.scroll_pos = max_scroll
		}
		if m.state.Conditions.scroll_pos < 0 {
			m.state.Conditions.scroll_pos = 0
		}
	} else {
		m.state.Conditions.scroll_pos = 0
		m.state.Actions.scroll_pos = 0
		m.state.Actions.scroll_target = 0
	}

	// Do a nice scroll motion towards the target position
	m.state.Actions.scroll_pos *= 0.8
	m.state.Actions.scroll_pos += 0.2 * m.state.Actions.scroll_target

	// Handle mouseover stuff after doing all of the scroll stuff since we don't
	// want to give a mouseover for something that the mouse isn't over after
	// scrolling something.
	m.state.MouseOver.active = false
	if m.ent != nil {
		c := m.layout.Conditions
		if pointInsideRect(m.mx, m.my, int(c.X), int(c.Y), int(c.Width), int(c.Height)) {
			pos := c.Y + c.Height + m.state.Conditions.scroll_pos - float64(m.my)
			index := int(pos / base.GetDictionary(int(c.Size)).MaxHeight())
			if index >= 0 && index < len(m.ent.Stats.ConditionNames()) {
				m.state.MouseOver.active = true
				m.state.MouseOver.text = m.ent.Stats.ConditionNames()[index]
				m.state.MouseOver.location = mouseOverConditions
			}
		}

		if index := m.pointInsideAction(m.mx, m.my); index != -1 {
			m.state.MouseOver.active = true
			m.state.MouseOver.text = m.ent.Actions[index].String()
			m.state.MouseOver.location = mouseOverActions
		}
	}

	buttons := m.no_actions_buttons
	if m.ent != nil && len(m.ent.Actions) > m.layout.Actions.Count {
		buttons = m.all_buttons
	}
	for _, button := range buttons {
		button.Think(m.region.X, m.region.Y, m.mx, m.my, t)
	}
}
开发者ID:RickDakan,项目名称:haunts,代码行数:95,代码来源:ui_main_bar.go


注:本文中的github.com/runningwild/glop/gui.Gui.FocusWidget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。