當前位置: 首頁>>代碼示例>>Golang>>正文


Golang EventGroup.FindEvent方法代碼示例

本文整理匯總了Golang中github.com/MobRulesGames/glop/gui.EventGroup.FindEvent方法的典型用法代碼示例。如果您正苦於以下問題:Golang EventGroup.FindEvent方法的具體用法?Golang EventGroup.FindEvent怎麽用?Golang EventGroup.FindEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/MobRulesGames/glop/gui.EventGroup的用法示例。


在下文中一共展示了EventGroup.FindEvent方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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:genbattle,項目名稱:haunts,代碼行數:33,代碼來源:summon.go

示例2: 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:genbattle,項目名稱:haunts,代碼行數:29,代碼來源:ui_start.go

示例3: 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:genbattle,項目名稱:haunts,代碼行數:28,代碼來源:ui_chooser.go

示例4: 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:genbattle,項目名稱:haunts,代碼行數:34,代碼來源:interact.go

示例5: HandleInput

func (a *BasicAttack) HandleInput(group gui.EventGroup, g *game.Game) (bool, game.ActionExec) {
	target := g.HoveredEnt()
	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		if target == nil || !a.validTarget(a.ent, target) {
			return true, nil
		}
		return true, a.makeExec(a.ent, target)
	}
	return false, nil
}
開發者ID:genbattle,項目名稱:haunts,代碼行數:10,代碼來源:basic_attack.go

示例6: 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.Choose(&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:genbattle,項目名稱:haunts,代碼行數:51,代碼來源:wall_tab.go

示例7: 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:genbattle,項目名稱:haunts,代碼行數:50,代碼來源:ui_online.go

示例8: 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 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.Space); found && event.Type == gin.Press {
		c.xscroll = 0
	}

	if group.Events[0].Type == gin.Press {
		r := rune(group.Events[0].Key.Id())
		if r < 256 {
			if gin.In().GetKey(gin.EitherShift).IsDown() {
				r = unicode.ToUpper(r)
			}
			c.cmd = append(c.cmd, byte(r))
		}
	}

	return group.Focus
}
開發者ID:genbattle,項目名稱:haunts,代碼行數:34,代碼來源:console.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:genbattle,項目名稱:haunts,代碼行數:48,代碼來源:ui_main_bar.go

示例10: Respond

func (mdb *MediumDialogBox) Respond(g *gui.Gui, group gui.EventGroup) bool {
	cursor := group.Events[0].Key.Cursor()
	if cursor != nil {
		mdb.mx, mdb.my = cursor.Point()
		if !pointInsideRect(mdb.mx, mdb.my, mdb.region.X, mdb.region.Y, mdb.layout.Background.Data().Dx(), mdb.layout.Background.Data().Dy()) {
			return false
		}
	}

	for _, button := range mdb.buttons {
		if button.Respond(group, mdb) {
			return true
		}
	}

	if found, event := group.FindEvent(gin.MouseLButton); found && event.Type == gin.Press {
		for _, button := range mdb.buttons {
			if button.handleClick(mdb.mx, mdb.my, mdb) {
				return true
			}
		}
		for i, section := range mdb.format.Sections {
			if pointInsideRect(
				mdb.mx,
				mdb.my,
				mdb.region.X+section.Region.X,
				mdb.region.Y+section.Region.Y,
				section.Region.Dx,
				section.Region.Dy) {
				if !mdb.done {
					mdb.data.prev = mdb.data.prev[0:0]
					mdb.result <- mdb.data.Pages[mdb.data.cur_page].Sections[i].Id
					mdb.data.cur_page = mdb.data.Pages[mdb.data.cur_page].Sections[i].Next
					if mdb.data.cur_page == "" {
						close(mdb.result)
						mdb.done = true
					} else {
						mdb.format = mdb.layout.Formats[mdb.data.Pages[mdb.data.cur_page].Format]
					}
					break
				}
			}
		}
	}

	return cursor != nil
}
開發者ID:genbattle,項目名稱:haunts,代碼行數:47,代碼來源:ui_dialog.go

示例11: 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:genbattle,項目名稱:haunts,代碼行數:21,代碼來源:ui_credits.go

示例12: 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:genbattle,項目名稱:haunts,代碼行數:21,代碼來源:aoe_attack.go

示例13: Respond

func (sm *SystemMenu) 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 {
		if sm.layout.Main.handleClick(sm.mx, sm.my, g) {
			if sm.focus {
				g.DropFocus()
			} else {
				g.TakeFocus(sm)
			}
			sm.focus = true
			base.Log().Printf("focus: %v %v", sm, g.FocusWidget())
			return true
		}
		if sm.focus {
			hit := false
			for _, button := range sm.buttons {
				if button.handleClick(sm.mx, sm.my, g) {
					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 (g.FocusWidget() == sm)
}
開發者ID:genbattle,項目名稱:haunts,代碼行數:40,代碼來源:ui_system.go

示例14: 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:genbattle,項目名稱:haunts,代碼行數:23,代碼來源:move.go

示例15: 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.Choose(&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:genbattle,項目名稱:haunts,代碼行數:47,代碼來源:house.go


注:本文中的github.com/MobRulesGames/glop/gui.EventGroup.FindEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。