private void buttonClicked(object sender, EventArgs e) { VerbButton button = (VerbButton)sender; Console.CurrentConsole.WriteLine(ConsoleSeverity.Debug, "Clicked verb: {0}", button.Verb); // TODO: this is temporary. Eventually we have to handle the approach // correctly. But for now we'll just teleport the actor to the location. if (button.Approach == Gk3Main.Game.NvcApproachType.WalkTo) { SceneManager.SetEgoToSifPosition(button.ApproachTarget); } Sheep.SheepMachine.RunCommand(button.Script); if (button.Verb == Game.Verbs.V_Z_CHAT) { Game.GameManager.IncrementChatCount(button.Noun); } else if (Game.VerbsUtils.IsTopicVerb(button.Verb)) { Game.GameManager.IncrementTopicCount(button.Noun, button.Verb); } Game.GameManager.IncrementNounVerbCount(button.Noun, button.Verb); }
public VerbButtonSet(Resource.ResourceManager content, int screenX, int screenY, List <Game.NounVerbCase> nvcs, bool cancel) { _screenX = screenX; _screenY = screenY; int buttonOffsetX = 0; foreach (Game.NounVerbCase nvc in nvcs) { // TODO: apparently the inventory verb is a special case. // for now just ignore it. if (nvc.Verb == Game.Verbs.V_ANY_INV_ITEM) { continue; } Game.VerbInfo info = Game.GameManager.Verbs[nvc.Verb]; VerbButton b = new VerbButton(this, content, nvc.Noun, nvc.Verb, nvc.Script, nvc.Approach, nvc.Target, string.Format("{0}.BMP", info.DownButton), string.Format("{0}.BMP", info.HoverButton), string.Format("{0}.BMP", info.UpButton), info.DisableButton != null ? string.Format("{0}.BMP", info.DisableButton) : null, null, info.Verb != Game.Verbs.V_NONE ? Game.GameManager.Strings.GetVerbTooltip(info.Verb) : null); b.X = new Unit(0, buttonOffsetX); b.OnClick += new EventHandler(buttonClicked); _buttons.Add(b); buttonOffsetX += ButtonWidth; } if (cancel) { Game.VerbInfo info = Game.GameManager.Verbs["t_cancel"]; Button b = new Button(this, content, string.Format("{0}.BMP", info.DownButton), string.Format("{0}.BMP", info.HoverButton), string.Format("{0}.BMP", info.UpButton), info.DisableButton != null ? string.Format("{0}.BMP", info.DisableButton) : null, null, Game.GameManager.Strings.GetVerbTooltip(info.Verb)); b.X = new Unit(0, buttonOffsetX); b.OnClick += delegate { cancelClicked(); }; _buttons.Add(b); buttonOffsetX += ButtonWidth; } // now that we've got all the buttons go back and center them around the cursor _screenX -= (_buttons.Count * ButtonWidth) / 2; _screenY -= ButtonWidth / 2; // assume the buttons are square }