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


Golang gui.EventGroup类代码示例

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


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

示例1: Respond

func (c *Chooser) Respond(g *gui.Gui, group gui.EventGroup) bool {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		c.mx, c.my = cursor.Point()
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		buttons := c.buttons
		if c.optionsHeight() <= c.layout.Options.Dy {
			buttons = c.non_scroll_buttons
		}
		for _, button := range buttons {
			if button.handleClick(c.mx, c.my, nil) {
				return true
			}
			clicked := false
			c.doOnOptions(func(index int, opt Option, data doOnOptionData) {
				if clicked {
					return
				}
				if data.hovered {
					c.selector(index, c.selected, true)
					clicked = true
				}
			})
		}
	}
	return false
}
开发者ID:ThalwegIII,项目名称:haunts,代码行数:28,代码来源:ui_chooser.go

示例2: Respond

func (c *Console) Respond(ui *gui.Gui, group gui.EventGroup) bool {
	if found, event := group.FindEvent(GetDefaultKeyMap()["console"].Id()); found && event.Type == gin.Press {
		if group.Focus {
			ui.DropFocus()
		} else {
			ui.TakeFocus(c)
		}
		return true
	}
	if group.Focus {
		// if found, event := group.FindEvent(gin.Left); found && event.Type == gin.Press {
		//   c.xscroll += 250
		// }
		// if found, event := group.FindEvent(gin.Right); found && event.Type == gin.Press {
		//   c.xscroll -= 250
		// }
	}
	if c.xscroll > 0 {
		c.xscroll = 0
	}
	if found, event := group.FindEvent(gin.AnySpace); found && event.Type == gin.Press {
		c.xscroll = 0
	}

	return group.Focus
}
开发者ID:dgthunder,项目名称:magnus,代码行数:26,代码来源:console.go

示例3: HandleInput

func (a *SummonAction) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		bx, by := g.GetViewer().WindowToBoard(cursor.Point())
		bx += 0.5
		by += 0.5
		if bx < 0 {
			bx--
		}
		if by < 0 {
			by--
		}
		a.cx = int(bx)
		a.cy = int(by)
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if g.IsCellOccupied(a.cx, a.cy) {
			return true, nil
		}
		if a.Personal_los && !a.ent.HasLos(a.cx, a.cy, 1, 1) {
			return true, nil
		}
		if a.ent.Stats.ApCur() >= a.Ap {
			var exec summonExec
			exec.SetBasicData(a.ent, a)
			exec.Pos = a.ent.Game().ToVertex(a.cx, a.cy)
			return true, &exec
		}
		return true, nil
	}
	return false, nil
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:33,代码来源:summon.go

示例4: Respond

func (sm *StartMenu) Respond(g *gui.Gui, group gui.EventGroup) bool {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		sm.mx, sm.my = cursor.Point()
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		hit := false
		for _, button := range sm.buttons {
			if button.handleClick(sm.mx, sm.my, nil) {
				hit = true
			}
		}
		if hit {
			return true
		}
	} else {
		hit := false
		for _, button := range sm.buttons {
			if button.Respond(group, nil) {
				hit = true
			}
		}
		if hit {
			return true
		}
	}
	return false
}
开发者ID:RickDakan,项目名称:haunts,代码行数:29,代码来源:ui_start.go

示例5: HandleInput

func (a *Interact) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		bx, by := g.GetViewer().WindowToBoard(gin.In().GetCursor("Mouse").Point())
		room_num := a.ent.CurrentRoom()
		room := g.House.Floors[0].Rooms[room_num]
		for door_num, door := range room.Doors {
			rect := makeRectForDoor(room, door)
			if rect.Contains(float64(bx), float64(by)) {
				var exec interactExec
				exec.Toggle_door = true
				exec.SetBasicData(a.ent, a)
				exec.Room = room_num
				exec.Door = door_num
				return true, &exec
			}
		}
	}
	target := g.HoveredEnt()
	if target == nil {
		return false, nil
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for i := range a.targets {
			if a.targets[i] == target && distBetweenEnts(a.ent, target) <= a.Range {
				var exec interactExec
				exec.SetBasicData(a.ent, a)
				exec.Target = target.Id
				return true, &exec
			}
		}
		return true, nil
	}
	return false, nil
}
开发者ID:RickDakan,项目名称:haunts,代码行数:34,代码来源:interact.go

示例6: Respond

func (sw *SaveWidget) Respond(ui *gui.Gui, event_group gui.EventGroup) bool {
	if found, event := event_group.FindEvent(gin.Return); found && event.Type == gin.Press {
		sw.on_save(sw.filename.GetText())
		return true
	}
	sw.VerticalTable.Respond(ui, event_group)
	return true
}
开发者ID:RickDakan,项目名称:haunts,代码行数:8,代码来源:save_widget.go

示例7: Respond

func (w *WallPanel) Respond(ui *gui.Gui, group gui.EventGroup) bool {
	if w.VerticalTable.Respond(ui, group) {
		return true
	}

	if found, event := group.FindEvent(gin.DeleteOrBackspace); found && event.Type == gin.Press {
		algorithm.Choose2(&w.room.WallTextures, func(wt *WallTexture) bool {
			return wt != w.wall_texture
		})
		w.wall_texture = nil
		w.prev_wall_texture = nil
		return true
	}

	if found, event := group.FindEvent(gin.Escape); found && event.Type == gin.Press {
		w.onEscape()
		return true
	}

	if found, event := group.FindEvent(base.GetDefaultKeyMap()["flip"].Id()); found && event.Type == gin.Press {
		if w.wall_texture != nil {
			w.wall_texture.Flip = !w.wall_texture.Flip
		}
		return true
	}
	if found, event := group.FindEvent(gin.MouseWheelVertical); found {
		if w.wall_texture != nil && gin.In().GetKey(gin.Space).CurPressAmt() == 0 {
			w.wall_texture.Rot += float32(event.Key.CurPressAmt() / 100)
		}
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if w.wall_texture != nil {
			w.wall_texture.temporary = false
			w.wall_texture = nil
		} else if w.wall_texture == nil {
			w.wall_texture = w.textureNear(event.Key.Cursor().Point())
			if w.wall_texture != nil {
				w.prev_wall_texture = new(WallTexture)
				*w.prev_wall_texture = *w.wall_texture
				w.wall_texture.temporary = true

				wx, wy := w.viewer.BoardToWindowf(w.wall_texture.X, w.wall_texture.Y)
				px, py := event.Key.Cursor().Point()
				w.drag_anchor.X = float32(px) - wx
				w.drag_anchor.Y = float32(py) - wy
			}
		}
		return true
	}
	return false
}
开发者ID:RickDakan,项目名称:haunts,代码行数:51,代码来源:wall_tab.go

示例8: Respond

func (sm *OnlineMenu) Respond(g *gui.Gui, group gui.EventGroup) bool {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		sm.mx, sm.my = cursor.Point()
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for _, button := range sm.buttons {
			if button.handleClick(sm.mx, sm.my, nil) {
				return true
			}
		}
		for _, glb := range []*gameListBox{&sm.layout.Active, &sm.layout.Unstarted} {
			inside := gui.Point{sm.mx, sm.my}.Inside(glb.Scroll.Region())
			if cursor == nil || inside {
				for _, game := range glb.games {
					if game.join.handleClick(sm.mx, sm.my, nil) {
						return true
					}
					if game.delete != nil && game.delete.handleClick(sm.mx, sm.my, nil) {
						return true
					}
				}
			}
		}
	}

	hit := false
	for _, button := range sm.buttons {
		if button.Respond(group, nil) {
			hit = true
		}
	}
	for _, glb := range []*gameListBox{&sm.layout.Active, &sm.layout.Unstarted} {
		inside := gui.Point{sm.mx, sm.my}.Inside(glb.Scroll.Region())
		if cursor == nil || inside {
			for _, game := range glb.games {
				if game.join.Respond(group, nil) {
					hit = true
				}
				if game.delete != nil && game.delete.Respond(group, nil) {
					hit = true
				}
			}
		}
	}
	if hit {
		return true
	}
	return false
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:50,代码来源:ui_online.go

示例9: 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

示例10: Respond

func (cm *CreditsMenu) Respond(g *gui.Gui, group gui.EventGroup) bool {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		cm.mx, cm.my = cursor.Point()
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for _, button := range cm.buttons {
			if button.handleClick(cm.mx, cm.my, nil) {
				return true
			}
		}
	}

	hit := false
	for _, button := range cm.buttons {
		if button.Respond(group, nil) {
			hit = true
		}
	}
	return hit
}
开发者ID:koomee,项目名称:haunts,代码行数:21,代码来源:ui_credits.go

示例11: HandleInput

func (a *AoeAttack) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil && cursor.Name() == "Mouse" {
		bx, by := g.GetViewer().WindowToBoard(cursor.Point())
		a.tx = int(bx)
		a.ty = int(by)
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		ex, ey := a.ent.Pos()
		if dist(ex, ey, a.tx, a.ty) <= a.Range && a.ent.HasLos(a.tx, a.ty, 1, 1) {
			var exec aoeExec
			exec.SetBasicData(a.ent, a)
			exec.X, exec.Y = a.tx, a.ty
			return true, &exec
		} else {
			return true, nil
		}
		return true, nil
	}
	return false, nil
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:21,代码来源:aoe_attack.go

示例12: HandleInput

func (a *Move) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		fx, fy := g.GetViewer().WindowToBoard(cursor.Point())
		a.findPath(a.ent, int(fx), int(fy))
	}
	if found, _ := group.FindEvent(gin.MouseLButton); found {
		if len(a.path) > 0 {
			if a.cost <= a.ent.Stats.ApCur() {
				var exec moveExec
				exec.SetBasicData(a.ent, a)
				algorithm.Map2(a.path, &exec.Path, func(v [2]int) int {
					return g.ToVertex(v[0], v[1])
				})
				return true, &exec
			}
			return true, nil
		} else {
			return false, nil
		}
	}
	return false, nil
}
开发者ID:hilerchyn,项目名称:haunts,代码行数:23,代码来源:move.go

示例13: Respond

func (ep *EntityPlacer) Respond(g *gui.Gui, group gui.EventGroup) bool {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		ep.mx, ep.my = cursor.Point()
	}

	// If we're dragging around an ent then we'll update its position here.
	if ep.game.new_ent != nil {
		bx, by := DiscretizePoint32(ep.game.viewer.WindowToBoard(ep.mx, ep.my))
		ep.game.new_ent.X, ep.game.new_ent.Y = float64(bx), float64(by)
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for _, button := range ep.buttons {
			if button.handleClick(ep.mx, ep.my, nil) {
				return true
			}
		}
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if pointInsideRect(ep.mx, ep.my, ep.region.X, ep.region.Y, ep.region.Dx, ep.region.Dy) {
			return true
		}
	}

	if ep.game.new_ent == nil {
		return false
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		ent := ep.game.new_ent
		if ep.game.placeEntity(ep.pattern) {
			cost := ep.roster[ent.Name]
			ep.points -= cost
			ep.ents = append(ep.ents, ent)
			sound.PlaySound("Haunts/SFX/UI/Place")
			if cost <= ep.points {
				ep.game.new_ent = MakeEntity(ent.Name, ep.game)
				ep.game.viewer.AddDrawable(ep.game.new_ent)
			}
			return true
		}
	}

	return false
}
开发者ID:ThalwegIII,项目名称:haunts,代码行数:47,代码来源:ui_entity_placer.go

示例14: Respond

func (hdt *houseRelicsTab) Respond(ui *gui.Gui, group gui.EventGroup) bool {
	if hdt.VerticalTable.Respond(ui, group) {
		return true
	}

	if found, event := group.FindEvent(gin.Escape); found && event.Type == gin.Press {
		hdt.onEscape()
		return true
	}

	if found, event := group.FindEvent(gin.DeleteOrBackspace); found && event.Type == gin.Press {
		algorithm.Choose2(&hdt.house.Floors[0].Spawns, func(s *SpawnPoint) bool {
			return s != hdt.temp_relic
		})
		hdt.temp_relic = nil
		hdt.prev_relic = nil
		return true
	}

	cursor := group.Events[0].Key.Cursor()
	floor := hdt.house.Floors[hdt.current_floor]
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if hdt.temp_relic != nil {
			if !hdt.temp_relic.invalid {
				hdt.temp_relic.temporary = false
				hdt.temp_relic = nil
			}
		} else {
			for _, sp := range floor.Spawns {
				fbx, fby := hdt.viewer.WindowToBoard(cursor.Point())
				bx, by := roundDown(fbx), roundDown(fby)
				x, y := sp.Pos()
				dx, dy := sp.Dims()
				if bx >= x && bx < x+dx && by >= y && by < y+dy {
					hdt.temp_relic = sp
					hdt.prev_relic = new(SpawnPoint)
					*hdt.prev_relic = *hdt.temp_relic
					hdt.temp_relic.temporary = true
					hdt.drag_anchor.x = fbx - float32(hdt.temp_relic.X)
					hdt.drag_anchor.y = fby - float32(hdt.temp_relic.Y)
					break
				}
			}
		}
	}
	return false
}
开发者ID:FlyingCar,项目名称:haunts,代码行数:47,代码来源:house.go

示例15: Respond

func (rc *RosterChooser) Respond(ui *gui.Gui, group gui.EventGroup) bool {
	base.Log().Printf("RosterChooser.Respond")
	if found, event := group.FindEvent('l'); found && event.Type == gin.Press {
		rc.focus += rc.layout.Num_options
		return true
	}
	if found, event := group.FindEvent('o'); found && event.Type == gin.Press {
		rc.focus -= rc.layout.Num_options
		return true
	}
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		x, y := event.Key.Cursor().Point()
		gp := gui.Point{x, y}
		if gp.Inside(rc.render.down) {
			rc.focus += rc.layout.Num_options
			return true
		} else if gp.Inside(rc.render.up) {
			rc.focus -= rc.layout.Num_options
			return true
		} else if gp.Inside(rc.render.all_options) {
			for i := range rc.render.options {
				if gp.Inside(rc.render.options[i]) {
					rc.selector(i, rc.selected, true)
					return true
				}
			}
		} else if gp.Inside(rc.render.done) {
			if rc.selector(-1, rc.selected, false) {
				base.Log().Printf("calling on-complete")
				rc.on_complete(rc.selected)
			}
			return true
		} else if rc.on_undo != nil && gp.Inside(rc.render.undo) {
			rc.on_undo()
			return true
		}
	}
	return false
}
开发者ID:RickDakan,项目名称:haunts,代码行数:39,代码来源:roster_chooser.go


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