Пример #1
0
	private void initUI() {
		Glade.XML xml = getGlade("MainWindow.glade");
		xml.Autoconnect(this);
		setupSelectedBlockType();

		fieldView = new FieldView();
		fieldView.OnMouseMove += OnFieldMouseMove;
		fieldView.OnSelectionChanged += OnFieldSelectionChanged;
		scrolledWindow.AddWithViewport(fieldView);
		fieldView.Show();

		splitPane.Position = 320;

		try {
			window.Icon = Gdk.Pixbuf.LoadFromResource("FieldEditor.ico");
		} catch (GLib.GException) {
			window.Icon = Gdk.Pixbuf.LoadFromResource("FieldEditor.FieldEditor.ico");
		} catch (ArgumentException) {
			window.Icon = Gdk.Pixbuf.LoadFromResource("FieldEditor.FieldEditor.ico");
		}
		window.Show();
	}
Пример #2
0
	private void OnFieldSelectionChanged(FieldView sender, FieldRegion selection) {
		if (selection != null) {
			selectedBlockType.Sensitive = true;

			if (selection.Left != selection.Right || selection.Top != selection.Bottom) {
				// More than 1 block has been selected.
				selectedCoord.Text = String.Format("({0}, {1}) - ({2}, {3})",
					selection.Left, selection.Top,
					selection.Right, selection.Bottom);

				BlockType type = sender.Field.GetBlock(selection.Left, selection.Top);
				bool same = true;
				for (uint x = selection.Left; x <= selection.Right && same; x++) {
					for (uint y = selection.Bottom; y <= selection.Top && same; y++) {
						same = sender.Field.GetBlock(x, y) == type;
					}
				}

				selectedBlockTypeChanging = true;
				ShowMixedType(!same, !same);
				if (same) {
					selectedBlockType.Active = (int) type;
				}
				selectedBlockTypeChanging = false;

			} else {
				// Only 1 block is selected.
				selectedCoord.Text = String.Format("({0}, {1})",
					selection.Left, selection.Top);
				selectedBlockTypeChanging = true;
				ShowMixedType(false, false);
				selectedBlockType.Active = (int) sender.Field.GetBlock(selection.Left, selection.Top);
				selectedBlockTypeChanging = false;
			}

		} else {
			selectedCoord.Text = "-";
			selectedBlockType.Sensitive = false;
		}
	}
Пример #3
0
	private void OnFieldMouseMove(FieldView sender, int x, int y) {
		if (x == -1 && y == -1) {
			currentCoord.Text = currentBlockType.Text = "-";
		} else {
			currentCoord.Text = String.Format("{0:d}, {1:d}", x, y);
			currentBlockType.Text = Field.BlockTypeToString(
				fieldView.Field.GetBlock((uint) x, (uint) y)
			);
		}
	}