void coinCenter_MouseDown(object sender, MouseEventArgs e) { if (!coin_interface.Checked) return; Vec2i mouse = new Vec2i(e.X, e.Y); if ((mouse - mCoinCenter).length() < 10) { mCoinCenterOffset = mouse - mCoinCenter; mCoinCenterDragging = true; } }
void coinCenter_MouseMove(object sender, MouseEventArgs e) { if (!mCoinCenterDragging) return; Vec2i mouse = new Vec2i(e.X, e.Y); if (mouse.x < 0) mouse.x = 0; if (mouse.x > coinCenter.Size.Width) mouse.x = coinCenter.Size.Width; if (mouse.y < 0) mouse.y = 0; if (mouse.y > coinCenter.Size.Height) mouse.y = coinCenter.Size.Height; mCoinCenter = mouse - mCoinCenterOffset; coinCenter.Invalidate(); }
public void setSize(int state, Vec2i size) { }
public void setHotspot(int state, Vec2i hotspot) { CharacterState cs = (CharacterState)mStates[state]; cs.basepoint = hotspot; mStates[state] = cs; }
public void drawBoundary(Graphics g, int state, Vec2i position, Color bordercolor) { Pen p = new Pen(bordercolor); const int span = 4; g.DrawLine(p, position.x - 1, position.y - 1, position.x + span, position.y - 1); g.DrawLine(p, position.x - 1, position.y - 1, position.x - 1, position.y + span); Vec2i size = mData.getSize(state); g.DrawLine(p, position.x + size.x, position.y - 1, position.x + size.x - span -1 , position.y - 1); g.DrawLine(p, position.x + size.x, position.y - 1, position.x + size.x, position.y + span); g.DrawLine(p, position.x - 1, position.y + size.y, position.x + span, position.y + size.y); g.DrawLine(p, position.x - 1, position.y + size.y, position.x - 1, position.y + size.y - span-1); g.DrawLine(p, position.x +size.x, position.y + size.y, position.x + size.x -span - 1, position.y + size.y); g.DrawLine(p, position.x +size.x, position.y + size.y, position.x + size.x, position.y + size.y - span - 1); }
public void setFramePartOffset(int state, int frame, int part, Vec2i offset) { }
public override bool isHit(Vec2i pos) { return(isHit(State, pos - Position)); }
public void setHotspot(int state, Vec2i hotspot) { CursorState cs = (CursorState)mStates[state]; cs.highlight = hotspot; mStates[state] = cs; }
private void setControls() { //first page this.projetName.Text = mData.Settings.Projectname; this.aspect_ratio.Checked = mData.Settings.Is16to9; this.aspect_ratio2.Checked = !mData.Settings.Is16to9; setResolution(aspect_ratio.Checked); if (mData.Settings.Resolution.y == 200) this.resolution.SelectedIndex = 0; else if (mData.Settings.Resolution.y == 240) this.resolution.SelectedIndex = 1; else if (mData.Settings.Resolution.x == 640) this.resolution.SelectedIndex = 2; else if (mData.Settings.Resolution.x == 800) this.resolution.SelectedIndex = 3; else if (mData.Settings.Resolution.x == 1024) this.resolution.SelectedIndex = 4; else if (mData.Settings.Resolution.x == 1440) this.resolution.SelectedIndex = 5; this.no_antialiasing.Checked = mData.Settings.NotAntialiased; this.mute_music.Checked = mData.Settings.MuteMusicWhenSpeech; if (mData.Settings.GameIcon.Length != 0) { mIcon = mData.Settings.GameIcon; try { Bitmap bmp = (Bitmap)Bitmap.FromFile(mIcon); this.symbol.Image = bmp; } catch (System.IO.FileNotFoundException) { MessageBox.Show("Cannot find icon " + mIcon); this.symbol.Image = null; } } else { mIcon = new string('a', 0); this.symbol.Image = null; } this.text_on.Checked = mData.Settings.TextOnOff; this.drawDraggedItems.Checked = mData.Settings.DrawDraggedItemIcons; this.groupItems.Checked = mData.Settings.GroupItems; this.actionText.Checked = mData.Settings.ActionText; this.actionTextHeight.Value = mData.Settings.ActionTextHeight; this.silentDelete.Checked = mData.Settings.SilentDelete; this.infoLine.Checked = mData.Settings.InfoLine; this.fitImages.Checked = mData.Persistence.FitImages; this.createBackups.Checked = mData.Persistence.CreateBackups; this.protectGamefiles.Checked = mData.Settings.ProtectGameFile; this.loadingImage.Text = mData.Settings.LoadingImage; this.settingsPicture.Text = mData.Settings.SettingsPicture; //second page this.start_script.Text = mData.Settings.Startscript; this.main_script.Text = mData.Settings.Mainscript; switch (mData.Settings.ScreenChange) { case ScreenChange.SC_DIRECT: this.sc_direct.Checked = true; break; case ScreenChange.SC_FADEOUT: this.sc_blackfade.Checked = true; break; case ScreenChange.SC_RECTANGLE: this.sc_blackfade.Checked = true; break; case ScreenChange.SC_CIRCLE: this.sc_circle.Checked = true; break; case ScreenChange.SC_CLOCK: this.sc_clock.Checked = true; break; case ScreenChange.SC_SHUTTERS: this.sc_shutters.Checked = true; break; case ScreenChange.SC_BLEND: this.sc_blend.Checked = true; break; case ScreenChange.SC_BLEND_SLOW: this.sc_blend_slow.Checked = true; break; } this.taskbar.Checked = mData.Settings.ShowTaskbar; this.taskBarHeight.Value = mData.Settings.TaskHeight; this.taskbar_room.Text = mData.Settings.TaskRoom; switch (mData.Settings.TaskPopup) { case 0: this.ts_always.Checked = true; break; case 1: this.ts_popup.Checked = true; break; case 2: this.ts_scrolling.Checked = true; break; } this.hideCompletely.Checked = mData.Settings.TaskHideCompletely; if (mData.Settings.TaskbarFromTop) { ts_appears_top.Checked = true; } else { ts_appear_bottom.Checked = true; } this.anywhere_room.Text = mData.Settings.AnywhereRoom; this.anywhere_transparency.Value = mData.Settings.AnywhereTransparency; //third page //this.border_color.BackColor = Color.FromArgb((int)(((System.UInt32)mData.Settings.BorderColor >> 8) & 0xffffff | ((System.UInt32)mData.Settings.BorderColor << 24) & 0xff000000)); this.border_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.BorderColor)); this.background_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.BackgroundColor)); this.text_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TextColor)); this.useCustomMenu.Checked = mData.Settings.CustomMenu; this.customMenu.Text = mData.Settings.CustomMenuRoom; this.menu_fading.Value = mData.Settings.MenuFading; this.offspeech_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.OffspeechColor)); this.infotext_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.InfotextColor)); this.transparent_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TargaColor)); //fourth page switch (mData.Settings.TsStyle) { case 0: this.ts_solid.Checked = true; break; case 1: this.ts_transparent.Checked = true; break; case 2: this.ts_additive.Checked = true; break; case 3: this.ts_none.Checked = true; break; } switch (mData.Settings.TsBorderStyle) { case 0: this.ts_rectangles.Checked = true; break; case 1: this.ts_lines.Checked = true; break; case 2: this.ts_box.Checked = true; break; case 3: this.ts_border_none.Checked = true; break; } this.textscene_fading.Value = mData.Settings.TextSceneFading; this.ts_area_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsAreaColor)); this.ts_border_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsBorderColor)); this.ts_text_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsTextColor)); this.ts_selection_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsSelectionColor)); if (mData.Settings.TsUseSymbols) this.ts_symbol.Checked = true; else this.ts_text.Checked = true; this.use_background_image.Checked = mData.Settings.TsUseBgImage; this.ts_background_image.Text = mData.Settings.TsBackground; //fifth page this.coin_interface.Checked = mData.Settings.CoinActivated; this.coin_room.Text = mData.Settings.CoinRoom; this.coin_autopopup.Checked = mData.Settings.CoinAutoPopup; this.coin_fading.Value = mData.Settings.CoinFading; //crosshair float xrange = (float)mData.Settings.CoinCenter.x / 190; float yrange = (float)mData.Settings.CoinCenter.y / 140; mCoinCenter = new Vec2i((int)(coinCenter.Size.Width * xrange), (int)(coinCenter.Size.Height * yrange)); this.coinCenter.Paint += new PaintEventHandler(coinCenter_Paint); this.coinCenter.MouseDown += coinCenter_MouseDown; this.coinCenter.MouseUp += coinCenter_MouseUp; this.coinCenter.MouseMove += coinCenter_MouseMove; //sixth page this.pngToJpeg.Checked = mData.Settings.PngToJpeg; this.cropTransparent.Checked = mData.Persistence.CropTransparentImages; this.scriptLang.SelectedIndex = (int)mData.Settings.ScriptingLanguage; }
public abstract void setPosition(Vec2i pos);
private void setControls() { //first page this.projetName.Text = mData.Settings.Projectname; this.aspect_ratio.Checked = mData.Settings.Is16to9; this.aspect_ratio2.Checked = !mData.Settings.Is16to9; setResolution(aspect_ratio.Checked); if (mData.Settings.Resolution.y == 200) { this.resolution.SelectedIndex = 0; } else if (mData.Settings.Resolution.y == 240) { this.resolution.SelectedIndex = 1; } else if (mData.Settings.Resolution.x == 640) { this.resolution.SelectedIndex = 2; } else if (mData.Settings.Resolution.x == 800) { this.resolution.SelectedIndex = 3; } else if (mData.Settings.Resolution.x == 1024) { this.resolution.SelectedIndex = 4; } else if (mData.Settings.Resolution.x == 1440) { this.resolution.SelectedIndex = 5; } this.no_antialiasing.Checked = mData.Settings.NotAntialiased; this.mute_music.Checked = mData.Settings.MuteMusicWhenSpeech; if (mData.Settings.GameIcon.Length != 0) { mIcon = mData.Settings.GameIcon; try { Bitmap bmp = (Bitmap)Bitmap.FromFile(mIcon); this.symbol.Image = bmp; } catch (System.IO.FileNotFoundException) { MessageBox.Show("Cannot find icon " + mIcon); this.symbol.Image = null; } } else { mIcon = new string('a', 0); this.symbol.Image = null; } this.text_on.Checked = mData.Settings.TextOnOff; this.drawDraggedItems.Checked = mData.Settings.DrawDraggedItemIcons; this.groupItems.Checked = mData.Settings.GroupItems; this.actionText.Checked = mData.Settings.ActionText; this.actionTextHeight.Value = mData.Settings.ActionTextHeight; this.silentDelete.Checked = mData.Settings.SilentDelete; this.infoLine.Checked = mData.Settings.InfoLine; this.fitImages.Checked = mData.Persistence.FitImages; this.createBackups.Checked = mData.Persistence.CreateBackups; this.protectGamefiles.Checked = mData.Settings.ProtectGameFile; this.loadingImage.Text = mData.Settings.LoadingImage; this.settingsPicture.Text = mData.Settings.SettingsPicture; //second page this.start_script.Text = mData.Settings.Startscript; this.main_script.Text = mData.Settings.Mainscript; switch (mData.Settings.ScreenChange) { case ScreenChange.SC_DIRECT: this.sc_direct.Checked = true; break; case ScreenChange.SC_FADEOUT: this.sc_blackfade.Checked = true; break; case ScreenChange.SC_RECTANGLE: this.sc_blackfade.Checked = true; break; case ScreenChange.SC_CIRCLE: this.sc_circle.Checked = true; break; case ScreenChange.SC_CLOCK: this.sc_clock.Checked = true; break; case ScreenChange.SC_SHUTTERS: this.sc_shutters.Checked = true; break; case ScreenChange.SC_BLEND: this.sc_blend.Checked = true; break; case ScreenChange.SC_BLEND_SLOW: this.sc_blend_slow.Checked = true; break; } this.taskbar.Checked = mData.Settings.ShowTaskbar; this.taskBarHeight.Value = mData.Settings.TaskHeight; this.taskbar_room.Text = mData.Settings.TaskRoom; switch (mData.Settings.TaskPopup) { case 0: this.ts_always.Checked = true; break; case 1: this.ts_popup.Checked = true; break; case 2: this.ts_scrolling.Checked = true; break; } this.hideCompletely.Checked = mData.Settings.TaskHideCompletely; if (mData.Settings.TaskbarFromTop) { ts_appears_top.Checked = true; } else { ts_appear_bottom.Checked = true; } this.anywhere_room.Text = mData.Settings.AnywhereRoom; this.anywhere_transparency.Value = mData.Settings.AnywhereTransparency; //third page //this.border_color.BackColor = Color.FromArgb((int)(((System.UInt32)mData.Settings.BorderColor >> 8) & 0xffffff | ((System.UInt32)mData.Settings.BorderColor << 24) & 0xff000000)); this.border_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.BorderColor)); this.background_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.BackgroundColor)); this.text_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TextColor)); this.useCustomMenu.Checked = mData.Settings.CustomMenu; this.customMenu.Text = mData.Settings.CustomMenuRoom; this.menu_fading.Value = mData.Settings.MenuFading; this.offspeech_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.OffspeechColor)); this.infotext_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.InfotextColor)); this.transparent_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TargaColor)); //fourth page switch (mData.Settings.TsStyle) { case 0: this.ts_solid.Checked = true; break; case 1: this.ts_transparent.Checked = true; break; case 2: this.ts_additive.Checked = true; break; case 3: this.ts_none.Checked = true; break; } switch (mData.Settings.TsBorderStyle) { case 0: this.ts_rectangles.Checked = true; break; case 1: this.ts_lines.Checked = true; break; case 2: this.ts_box.Checked = true; break; case 3: this.ts_border_none.Checked = true; break; } this.textscene_fading.Value = mData.Settings.TextSceneFading; this.ts_area_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsAreaColor)); this.ts_border_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsBorderColor)); this.ts_text_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsTextColor)); this.ts_selection_color.BackColor = Color.FromArgb(Utilities.convertColor(mData.Settings.TsSelectionColor)); if (mData.Settings.TsUseSymbols) { this.ts_symbol.Checked = true; } else { this.ts_text.Checked = true; } this.use_background_image.Checked = mData.Settings.TsUseBgImage; this.ts_background_image.Text = mData.Settings.TsBackground; //fifth page this.coin_interface.Checked = mData.Settings.CoinActivated; this.coin_room.Text = mData.Settings.CoinRoom; this.coin_autopopup.Checked = mData.Settings.CoinAutoPopup; this.coin_fading.Value = mData.Settings.CoinFading; //crosshair float xrange = (float)mData.Settings.CoinCenter.x / 190; float yrange = (float)mData.Settings.CoinCenter.y / 140; mCoinCenter = new Vec2i((int)(coinCenter.Size.Width * xrange), (int)(coinCenter.Size.Height * yrange)); this.coinCenter.Paint += new PaintEventHandler(coinCenter_Paint); this.coinCenter.MouseDown += coinCenter_MouseDown; this.coinCenter.MouseUp += coinCenter_MouseUp; this.coinCenter.MouseMove += coinCenter_MouseMove; //sixth page this.pngToJpeg.Checked = mData.Settings.PngToJpeg; this.cropTransparent.Checked = mData.Persistence.CropTransparentImages; this.scriptLang.SelectedIndex = (int)mData.Settings.ScriptingLanguage; }
public int[] createBitmapFont(int idx, out Bitmap[] images, out Bitmap[] alphaimages, out Vec2i dims, out Vec2i numchars) { //font setup mCurrInfo = (FontInfo)mData.Settings.Fonts[idx - 1]; mCurrFont = new Font(mCurrInfo.name, mCurrInfo.size); if (mCurrInfo.bold) { mCurrFont = new Font(mCurrFont, FontStyle.Bold); } if (mCurrInfo.italic) { mCurrFont = new Font(mCurrFont, FontStyle.Italic); } int outlinethickness = 0; int shadowthickness = 0; if (mCurrInfo.outline == 1 || mCurrInfo.outline == 2) { outlinethickness = 1; } else if (mCurrInfo.outline == 3) { outlinethickness = 2; } if (mCurrInfo.shadow != 0) { shadowthickness = 3; } //character dimension measuring Bitmap bmp = new Bitmap(256, 256); Graphics g = Graphics.FromImage(bmp); g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; int maxwidth = 0, maxheight = 0; int[] charwidths = new int[224]; StringFormat fmt = new StringFormat(); fmt.FormatFlags = StringFormatFlags.NoClip; CharacterRange[] range = new CharacterRange[1]; range[0] = new CharacterRange(0, 1); fmt.SetMeasurableCharacterRanges(range); Encoding enc = Encoding.GetEncoding(1252); byte [] b = new byte[1]; for (int i = 0; i < 224; ++i) { b[0] = (byte)(i + 0x20); char[] chs = enc.GetChars(b); char ch = chs[0]; Region[] reg = g.MeasureCharacterRanges(new string(ch, 1), mCurrFont, new RectangleF(0, 0, 256, 256), fmt); RectangleF rect = reg[0].GetBounds(g); int width = (int)rect.Width;///*Math.Ceiling(*/ f.Width;//); if (width == 0) { SizeF f = g.MeasureString(new string(ch, 1), mCurrFont); width = (int)f.Width; } charwidths[i] = width + outlinethickness + mCurrInfo.spacing; maxwidth = Math.Max(maxwidth, (int)(rect.Width + rect.X)); int height = (int)(rect.Height + rect.Y); if (height > 256) { continue; } maxheight = Math.Max(maxheight, height); } if (maxheight == 0) { maxheight = maxwidth;//a crappy workaround to compensate for crappy fonts } int charwidth = maxwidth + outlinethickness + shadowthickness; int charheight = maxheight + 2 + outlinethickness + shadowthickness; int charsperrow = 256 / charwidth; int numrows = 256 / charheight; int numtextures = (int)Math.Ceiling(224.0 / (charsperrow * numrows)); //allocate bitmaps images = new Bitmap[numtextures]; alphaimages = new Bitmap[numtextures]; int currtexture = -1; Graphics g2 = null; //render bitmap font for (int i = 0; i < 224; ++i) { b[0] = (byte)(i + 0x20); char[] chs = enc.GetChars(b); char ch = chs[0]; int texture = i / (numrows * charsperrow); if (texture != currtexture) { images[texture] = new Bitmap(256, 256, PixelFormat.Format16bppRgb565); g.Dispose(); g = Graphics.FromImage(images[texture]); g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; g.SmoothingMode = SmoothingMode.AntiAlias; g.Clear(Color.Black); alphaimages[texture] = new Bitmap(256, 256, PixelFormat.Format16bppRgb565); if (g2 != null) { g2.Dispose(); } g2 = Graphics.FromImage(alphaimages[texture]); g2.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; g2.SmoothingMode = SmoothingMode.AntiAlias; g2.Clear(Color.Black); currtexture = texture; } int row = i / charsperrow - texture * numrows; int column = i % charsperrow; drawText(g, column * charwidth, row * charheight, new string(ch, 1), fmt); drawText(g2, column * charwidth, row * charheight, new string(ch, 1), fmt, true); } g.Dispose(); g2.Dispose(); dims = new Vec2i(charwidth, charheight); numchars = new Vec2i(charsperrow, numrows); return(charwidths); }
private void getControls() { //first page mData.Settings.Projectname = this.projetName.Text; switch (this.resolution.SelectedIndex) { case 0: mData.Settings.Resolution = new Vec2i(320, 200); break; case 1: mData.Settings.Resolution = new Vec2i(320, 240); break; case 2: mData.Settings.Resolution = new Vec2i(640, 480); break; case 3: mData.Settings.Resolution = new Vec2i(800, 600); break; case 4: mData.Settings.Resolution = new Vec2i(1024, 768); break; case 5: mData.Settings.Resolution = new Vec2i(1440, 1080); break; } mData.Settings.Is16to9 = this.aspect_ratio.Checked; mData.Settings.NotAntialiased = this.no_antialiasing.Checked; mData.Settings.MuteMusicWhenSpeech = this.mute_music.Checked; mData.Settings.GameIcon = mIcon; mData.Settings.TextOnOff = this.text_on.Checked; mData.Settings.DrawDraggedItemIcons = this.drawDraggedItems.Checked; mData.Settings.GroupItems = this.groupItems.Checked; mData.Settings.ActionText = this.actionText.Checked; mData.Settings.ActionTextHeight = (int)this.actionTextHeight.Value; mData.Settings.SilentDelete = this.silentDelete.Checked; mData.Settings.InfoLine = this.infoLine.Checked; mData.Persistence.FitImages = this.fitImages.Checked; mData.Persistence.CreateBackups = this.createBackups.Checked; mData.Settings.ProtectGameFile = this.protectGamefiles.Checked; mData.Settings.LoadingImage = this.loadingImage.Text; mData.Settings.SettingsPicture = this.settingsPicture.Text; //second page mData.Settings.Startscript = this.start_script.Text; mData.Settings.Mainscript = this.main_script.Text; if (sc_direct.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_DIRECT; } else if (sc_blackfade.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_FADEOUT; } else if (sc_rectangle.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_RECTANGLE; } else if (sc_circle.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_CIRCLE; } else if (sc_clock.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_CLOCK; } else if (sc_shutters.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_SHUTTERS; } else if (sc_blend.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_BLEND; } else if (sc_blend_slow.Checked) { mData.Settings.ScreenChange = ScreenChange.SC_BLEND_SLOW; } mData.Settings.ShowTaskbar = this.taskbar.Checked; mData.Settings.TaskHeight = (int)this.taskBarHeight.Value; mData.Settings.TaskRoom = this.taskbar_room.Text; if (this.ts_always.Checked) { mData.Settings.TaskPopup = 0; } else if (this.ts_popup.Checked) { mData.Settings.TaskPopup = 1; } else if (this.ts_scrolling.Checked) { mData.Settings.TaskPopup = 2; } mData.Settings.TaskHideCompletely = this.hideCompletely.Checked; if (this.ts_appears_top.Checked) { mData.Settings.TaskbarFromTop = true; } else { mData.Settings.TaskbarFromTop = false; } mData.Settings.AnywhereRoom = this.anywhere_room.Text; mData.Settings.AnywhereTransparency = (int)this.anywhere_transparency.Value; //third page mData.Settings.BorderColor = Utilities.convertColorInverse(this.border_color.BackColor.ToArgb()); mData.Settings.BackgroundColor = Utilities.convertColorInverse(this.background_color.BackColor.ToArgb()); mData.Settings.TextColor = Utilities.convertColorInverse(this.text_color.BackColor.ToArgb()); mData.Settings.CustomMenu = this.useCustomMenu.Checked; mData.Settings.CustomMenuRoom = this.customMenu.Text; mData.Settings.MenuFading = (int)this.menu_fading.Value; mData.Settings.OffspeechColor = Utilities.convertColorInverse(this.offspeech_color.BackColor.ToArgb()); mData.Settings.InfotextColor = Utilities.convertColorInverse(this.infotext_color.BackColor.ToArgb()); mData.Settings.TargaColor = Utilities.convertColorInverse(this.transparent_color.BackColor.ToArgb()); //fourth page if (this.ts_solid.Checked) { mData.Settings.TsStyle = 0; } else if (this.ts_transparent.Checked) { mData.Settings.TsStyle = 1; } else if (this.ts_additive.Checked) { mData.Settings.TsStyle = 2; } else if (this.ts_none.Checked) { mData.Settings.TsStyle = 3; } if (this.ts_rectangles.Checked) { mData.Settings.TsBorderStyle = 0; } else if (this.ts_lines.Checked) { mData.Settings.TsBorderStyle = 1; } else if (this.ts_box.Checked) { mData.Settings.TsBorderStyle = 2; } else if (this.ts_border_none.Checked) { mData.Settings.TsBorderStyle = 3; } mData.Settings.TextSceneFading = (int)this.textscene_fading.Value; mData.Settings.TsAreaColor = Utilities.convertColorInverse(this.ts_area_color.BackColor.ToArgb()); mData.Settings.TsBorderColor = Utilities.convertColorInverse(this.ts_border_color.BackColor.ToArgb()); mData.Settings.TsTextColor = Utilities.convertColorInverse(this.ts_text_color.BackColor.ToArgb()); mData.Settings.TsSelectionColor = Utilities.convertColorInverse(this.ts_selection_color.BackColor.ToArgb()); if (this.ts_symbol.Checked) { mData.Settings.TsUseSymbols = true; } else { mData.Settings.TsUseSymbols = false; } mData.Settings.TsUseBgImage = this.use_background_image.Checked; mData.Settings.TsBackground = this.ts_background_image.Text; //fifth page mData.Settings.CoinActivated = this.coin_interface.Checked; mData.Settings.CoinRoom = this.coin_room.Text; mData.Settings.CoinAutoPopup = this.coin_autopopup.Checked; mData.Settings.CoinFading = (int)this.coin_fading.Value; //crosshair float xrange = (float)mCoinCenter.x / coinCenter.Size.Width; float yrange = (float)mCoinCenter.y / coinCenter.Size.Height; mData.Settings.CoinCenter = mCoinCenter = new Vec2i((int)(190 * xrange), (int)(140 * yrange)); //sixth page mData.Settings.PngToJpeg = this.pngToJpeg.Checked; mData.Persistence.CropTransparentImages = this.cropTransparent.Checked; mData.Settings.ScriptingLanguage = (ProjectSettings.ScriptLang) this.scriptLang.SelectedIndex; }
void pictureBox_Paint(object sender, PaintEventArgs e) { if (mData == null) { return; } string[] pics = mData.getFrame(mState, mFrame); if (pics == null) { imageNames.Text = "none"; if (mDrawHotspot) { Utilities.drawCrosshair(e.Graphics, mData.getHotspot(mState) * mHotspotScale); } if (PictureChanged != null) { PictureChanged(this, new EventArgs()); } return; } if (!mTimer.Enabled && mPictureDragging == 0) { imageNames.Text = ""; } for (int i = 0; i < pics.Length; ++i) { if (pics[i] == null) { continue; } if (!mTimer.Enabled && mPictureDragging == 0) { imageNames.Text += pics[i] + " "; } System.Drawing.Bitmap bmp = mData.getImage(pics[i]); if (bmp == null) { continue; } Vec2i offset = mData.getFramePartOffset(mState, mFrame, i); Pen pen; if (i == mSelectedPart) { pen = new Pen(Color.Yellow); } else { pen = new Pen(Color.Red); } pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom; pen.DashPattern = new float[] { 3, 3 }; pen.DashOffset = 3.0f; if (mScaleImage) { e.Graphics.DrawImage(bmp, 0, 0, PictureBoxSize.Width, PictureBoxSize.Height); e.Graphics.DrawRectangle(pen, -1, -1, PictureBoxSize.Width + 1, PictureBoxSize.Height + 1); } else { e.Graphics.DrawImage(bmp, offset.x, offset.y, bmp.Width, bmp.Height); e.Graphics.DrawRectangle(pen, offset.x - 1, offset.y - 1, bmp.Width + 1, bmp.Height + 1); } } if (mDrawHotspot) { Utilities.drawCrosshair(e.Graphics, mData.getHotspot(mState) * mHotspotScale); } if (PictureChanged != null) { PictureChanged(this, new EventArgs()); } }
public override void setPosition(Vec2i pos) { Position = pos; }
public void addWalkmapScript(Script scr, Vec2i pos, string roomname) { addScript(scr); }
public AdvObject(AdvData data, int numStates) { mData = data; Name = "Object" + (mData.NumObjects + 1); mSize = new Vec2i(100, 100); for (int state = 0; state < numStates; ++state) { ObjectState ost = new ObjectState(); ost.frames = new System.Collections.ArrayList(); ost.fpsDivider = 20; Add(ost); } }
void pictureBox_MouseMove(object sender, MouseEventArgs e) { if (mPictureDragging == 0) return; Vec2i mouse = new Vec2i(e.X, e.Y); if (mouse.x < 0) mouse.x = 0; if (mouse.x > pictureBox.Size.Width) mouse.x = pictureBox.Size.Width; if (mouse.y < 0) mouse.y = 0; if (mouse.y > pictureBox.Size.Height) mouse.y = pictureBox.Size.Height; if (mPictureDragging == 100) mData.setHotspot(mState, (mouse-mDraggingOffset) / mHotspotScale); else { mData.setFramePartOffset(mState, mFrame, mPictureDragging - 1, mouse-mDraggingOffset); } pictureBox.Invalidate(); }
public void setSize(int state, Vec2i size) { mSize = size; }
protected int readExtendedFrames(StreamReader rdr, System.Collections.ArrayList frames) { string str; int realFrames = 0; for (int frms = 0; frms < FRAMES2_MAX; ++frms) { ExtendedFrame frm = new ExtendedFrame(); bool[] set = new bool[PARTS_MAX]; for (int parts = 0; parts < PARTS_MAX; ++parts) { str = rdr.ReadLine(); if (str.Length > 0) { set[parts] = true; frm.names.Add(str); } } //read offsets str = rdr.ReadLine(); string[] split = str.Split(';'); for (int i = 0; i < PARTS_MAX; ++i) { if (!set[i]) continue; Vec2i offset = new Vec2i(Convert.ToInt32(split[2*i]), Convert.ToInt32(split[2*i+1])); frm.offsets.Add(offset); } if (set[0] || set[1]) realFrames = frms+1; if (split.Length > PARTS_MAX * 2) frm.script = split[PARTS_MAX * 2].Replace('\xaf', ';'); frames.Add(frm); } frames.RemoveRange(realFrames, FRAMES2_MAX - realFrames); str = rdr.ReadLine(); return Convert.ToInt32(str); }
public override bool isHit(Vec2i pos) { return(isHit(LookDir, pos - RawPosition)); }
public void setFramePartOffset(int state, int frame, int part, Vec2i offset) { ObjectState os = (ObjectState)mStates[state]; ExtendedFrame extfrm = (ExtendedFrame)os.frames[frame]; extfrm.offsets[part] = offset; }
Vec2i clickToWalkmap(int x, int y) { Vec2i ret = new Vec2i(x, y); ret.x += mRoom.ScrollOffset.x; ret.y += mRoom.ScrollOffset.y; int wmscale = mRoom.DoubleWalkmap ? 2 : 1; ret.x = wmscale * ret.x / mData.WalkGridSize; ret.y = wmscale * ret.y / mData.WalkGridSize; return ret; }
public CharacterState() { frames = new ArrayList(); fpsDivider = 20; size = new Vec2i(120, 200); basepoint = new Vec2i(60, 199); }
private void copyWalkmapScriptToolStripMenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem item1 = menuWalkmap.Items[6] as ToolStripMenuItem; ToolStripMenuItem item2 = menuWalkmap.Items[10] as ToolStripMenuItem; item1.Enabled = true; item2.Enabled = true; Vec2i pos = new Vec2i(mMousePos.x / mData.WalkGridSize, mMousePos.y / mData.WalkGridSize); string scrname = Script.toScriptName(pos.x, pos.y, mRoom.Name, mData); Script scr = mData.getScript(Script.Type.WALKMAP, scrname); mCopiedWMScript = scr.Text; }
public void draw(Graphics g, int state, Vec2i position) { if (state == 0) { return; } string[] parts = mData.getFrame(state - 1, 0); if (parts == null) { return; } for (int i = 0; i < parts.Length; ++i) { if (parts[i] == null) continue; System.Drawing.Bitmap bmp = mData.getImage(parts[i]); Vec2i offset = mData.getFramePartOffset(state - 1, 0, i); g.DrawImage(bmp, position.x + offset.x, position.y + offset.y, bmp.Width, bmp.Height); } }
private void correctShapeBoundary(int index, Vec2i correctingDiff, ref Vec2i diff) { for (int j = 0; j <= index; ++j) { mDraggingShape.Positions[j] += correctingDiff; } diff += correctingDiff; }
public bool isHit(int state, Vec2i position) { if (position.x < 0 || position.y < 0) return false; Vec2i size = mData.getSize(state); if (position.x > size.x || position.y > size.y) return false; return true; }
private void editScriptToolStripMenuItem_Click(object sender, EventArgs e) { Vec2i pos = new Vec2i(mMousePos.x /mData.WalkGridSize, mMousePos.y / mData.WalkGridSize); mRoom.Walkmap[pos.x, pos.y].hasScript = true; MainForm form = mOwner; string scrname = Script.toScriptName(pos.x, pos.y, mRoom.Name, mData); form.showScript(Script.Type.WALKMAP, scrname); }
public void setHotspot(int state, Vec2i hotspot) { }
private DrawableObject getObjectAt(Vec2i pos, bool secondObject) { DrawableObject ret = null; DrawableObject ret2 = null; int retdepth = -1; int secretdepth = -1; foreach (ObjectInstance obj in mRoom.Objects) { if (obj.isHit(pos)) { int depth = getDepth(obj); if (depth >= retdepth) { secretdepth = retdepth; retdepth = depth; ret2 = ret; ret = obj; } } } foreach (CharacterInstance chr in mRoom.Characters) { if (chr.isHit(pos)) { int depth = getDepth(chr); if (depth > retdepth) { secretdepth = retdepth; retdepth = depth; ret2 = ret; ret = chr; } else if (depth > secretdepth) { secretdepth = depth; ret2 = chr; } } } return secondObject ? ret2 : ret; }
public void setFramePartOffset(int state, int frame, int part, Vec2i offset) { CharacterState cs = (CharacterState)mStates[state]; ExtendedFrame extfrm = (ExtendedFrame)cs.frames[frame]; extfrm.offsets[part] = offset; }
void RoomDlg_MouseDown(object sender, MouseEventArgs e) { Point click = new Point(e.X, e.Y); Vec2i pos = new Vec2i(e.X, e.Y); mMousePos = pos; if (mMode == ViewMode.Objects) { bool dragDepthFound = false; foreach (ObjectInstance obj in mRoom.Objects) { if (obj.Layer != 1) continue; Vec2i depthcenter = new Vec2i(obj.Position.x, obj.Depth * mData.WalkGridSize/2 - mData.WalkGridSize / 4); if ((depthcenter - pos - mRoom.ScrollOffset).length() <= 5) { mDragObject = obj; mDragOffset = depthcenter - pos; mDragDepth = true; dragDepthFound = true; break; } } if (!dragDepthFound) { mDragDepth = false; bool dragSecond = e.Button == MouseButtons.Middle; mDragObject = getObjectAt(pos + mRoom.ScrollOffset, dragSecond); mControl.SelectedObject = mDragObject; if (mDragObject != null) { mDragOffset = mDragObject.getPosition() - pos; } } if (e.Button == MouseButtons.Right) { if (mDragObject != null) { if (mDragObject.GetType() == typeof(ObjectInstance)) menuObject.Items[2].Text = "Show in Object window"; else menuObject.Items[2].Text = "Show in Character window"; menuObject.Show(this, click); } else menuRemoveBackground.Show(this, click); } } else if (mMode == ViewMode.Walkmap) { if (e.Button == MouseButtons.Right) { Vec2i cp = clickToWalkmap(e.X, e.Y); ToolStripMenuItem it = menuWalkmap.Items[9] as ToolStripMenuItem; if (mRoom.Walkmap[cp.x, cp.y].hasScript) { it.Enabled = true; } else it.Enabled = false; menuWalkmap.Show(this, click); return; } modifyWalkmap(pos.x, pos.y); mDragDepth = true; } else if (mMode == ViewMode.Deepmap) { int depth = (e.Y+mData.WalkGridSize/2+mRoom.ScrollOffset.y) / mData.WalkGridSize; if (depth == mRoom.Depthmap.x) mDragDepth = true; if (depth == mRoom.Depthmap.y) mDragDepthBottom = true; } else if (mMode == ViewMode.Inventory) { if (mRoom.HasInventory) { if (e.Button == MouseButtons.Right) { menuInventory.Show(this, click); } int sizex = mRoom.InvSize.x * ((int)(50 * mRoom.InvScale.x) + mRoom.InvSpacing) + 30; int sizey = mRoom.InvSize.y * ((int)(50 * mRoom.InvScale.y) + mRoom.InvSpacing) + 5; int ydown = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey; int xmiddle = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex / 2; int ymiddle = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey / 2; int xright = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex; int xleft = -mRoom.ScrollOffset.x + mRoom.InvPos.x; int yup = -mRoom.ScrollOffset.y + mRoom.InvPos.y; //bottom if (e.X >= xmiddle - 15 && e.X <= xmiddle + 15) { if (e.Y <= ydown + 3 && e.Y >= ydown - 5 - 3) { mDragMode = DragMode.DragBottom; mDragOffset.y = e.Y - ydown; } else mDragMode = DragMode.DragNone; } //right else if (e.Y >= ymiddle - 15 && e.Y <= ymiddle + 15) { if (e.X <= xright + 3 && e.X >= xright - 5 - 3) { mDragMode = DragMode.DragRight; mDragOffset.x = e.X - xright; } else mDragMode = DragMode.DragNone; } //corner else if (e.X >= xright - 11 - 3 && e.X <= xright + 3) { if (e.Y >= ydown - 11 - 3 && e.Y <= ydown + 3) mDragMode = DragMode.DragCorner; else mDragMode = DragMode.DragNone; } else mDragMode = DragMode.DragNone; //elsewhere on inventory if (mDragMode == DragMode.DragNone && e.X >= xleft && e.X <= xright) { if (e.Y >= yup && e.Y <= ydown) { mDragMode = DragMode.DragPosition; mDragOffset = new Vec2i(e.X, e.Y) - mRoom.InvPos; } } } else { if (e.Button == MouseButtons.Right) { return; } mRoom.InvPos = new Vec2i(e.X + mRoom.ScrollOffset.x, e.Y + mRoom.ScrollOffset.y); mRoom.InvScale = new Vec2f(1.0f, 1.0f); mRoom.HasInventory = true; mDragMode = DragMode.DragCorner; this.Cursor = Cursors.SizeNWSE; } } else if (mMode == ViewMode.Specialfx) { Vec2i clickpos = pos; clickpos += mRoom.ScrollOffset; for (int shapeidx = 0; shapeidx < mRoom.FXShapes.Count; ++shapeidx) { FxShape shape = (FxShape)mRoom.FXShapes[shapeidx]; if (!shape.Active) continue; Vec2i center = new Vec2i(); for (int i = 0; i < shape.Positions.Length; ++i) { if ((shape.Positions[i] - clickpos).length() <= 4) { mDragMode = DragMode.DragCorner; mDraggingShape = shape; mShapeIndex = i; mDragOffset = clickpos - center; return; } center += shape.Positions[i]; } center /= shape.Positions.Length; if ((center - clickpos).length() <= 10) { mDragMode = DragMode.DragPosition; mDraggingShape = shape; mDragOffset = pos; break; } Vec2i depthcenter = new Vec2i(center.x, (int)((shape.Depth + 0.5f) * mData.WalkGridSize - mData.WalkGridSize / 2)); if ((depthcenter - clickpos).length() <= 5) { mDragMode = DragMode.DragBottom; mDraggingShape = shape; mDragOffset = depthcenter - pos; return; } } } }
public void setSize(int state, Vec2i size) { CharacterState cs = (CharacterState)mStates[state]; cs.size = size; mStates[state] = cs; }
void RoomDlg_MouseMove(object sender, MouseEventArgs e) { mMousePos.x = e.X; mMousePos.y = e.Y; Invalidate(); if (mMode == ViewMode.Objects) { if (mDragObject == null) return; if (mDragObject.isLocked() && !mDragDepth) return; Vec2i pos = new Vec2i(e.X, e.Y); if (mDragDepth) { ObjectInstance obj = (ObjectInstance)mDragObject; obj.Depth = (int)((e.Y + 5 + mDragOffset.y + mData.WalkGridSize / 4.0f) / (mData.WalkGridSize/2.0f)); if (obj.Depth < 1) obj.Depth = 1; if (obj.Depth > mRoom.Size.y / (mData.WalkGridSize/2) - 2) obj.Depth = mRoom.Size.y / (mData.WalkGridSize/2) - 2; } else { mDragObject.setPosition(pos + mDragOffset); } } else if (mMode == ViewMode.Walkmap) { if (!mDragDepth) return; modifyWalkmap(e.X, e.Y); } else if (mMode == ViewMode.Deepmap) { int depth = (e.Y + mData.WalkGridSize / 2 + mRoom.ScrollOffset.y) / mData.WalkGridSize; if (mDragDepth) { if (depth < 1) depth = 1; if (depth >= mRoom.Depthmap.y) depth = mRoom.Depthmap.y - 1; mRoom.Depthmap.x = depth; } if (mDragDepthBottom) { if (depth <= mRoom.Depthmap.x) depth = mRoom.Depthmap.x + 1; if (depth >= mRoom.Size.y/mData.WalkGridSize) depth = mRoom.Size.y/mData.WalkGridSize-1; mRoom.Depthmap.y = depth; } } else if (mMode == ViewMode.Inventory) { if (mDragMode == DragMode.DragNone) { int sizex = mRoom.InvSize.x * ((int)(50 * mRoom.InvScale.x) + mRoom.InvSpacing) + 30; int sizey = mRoom.InvSize.y * ((int)(50 * mRoom.InvScale.y) + mRoom.InvSpacing) + 5; int ydown = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey; int xmiddle = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex / 2; //e.Graphics.DrawLine(tbp, xmiddle - 15, ydown - 3, xmiddle + 15, ydown - 3); int ymiddle = -mRoom.ScrollOffset.y + mRoom.InvPos.y + sizey / 2; int xright = -mRoom.ScrollOffset.x + mRoom.InvPos.x + sizex; //bottom if (e.X >= xmiddle - 15 && e.X <= xmiddle + 15) { if (e.Y <= ydown + 3 && e.Y >= ydown - 5 - 3) this.Cursor = Cursors.SizeNS; else this.Cursor = Cursors.Default; } //right else if (e.Y >= ymiddle - 15 && e.Y <= ymiddle + 15) { if (e.X <= xright + 3 && e.X >= xright - 5 - 3) this.Cursor = Cursors.SizeWE; else this.Cursor = Cursors.Default; } //corner else if (e.X >= xright - 11 - 3 && e.X <= xright + 3) { if (e.Y >= ydown - 11 - 3 && e.Y <= ydown + 3) this.Cursor = Cursors.SizeNWSE; else this.Cursor = Cursors.Default; } else this.Cursor = Cursors.Default; } else if (mDragMode == DragMode.DragCorner) { int maxX = (int)((mData.Settings.Resolution.x - 30) / 60); int maxY = (int)((mData.Settings.Resolution.y - 5) / 60); mRoom.InvSize.x = (int)Math.Round((e.X + mRoom.ScrollOffset.x - mRoom.InvPos.x - 30) / (mRoom.InvScale.x * 50 + mRoom.InvSpacing)); if (mRoom.InvSize.x < 1) mRoom.InvSize.x = 1; if (mRoom.InvSize.x > maxX) mRoom.InvSize.x = maxX; mRoom.InvSize.y = (int)Math.Round((e.Y + mRoom.ScrollOffset.y - mRoom.InvPos.y - 5) / (mRoom.InvScale.y * 50 + mRoom.InvSpacing)); if (mRoom.InvSize.y < 1) mRoom.InvSize.y = 1; if (mRoom.InvSize.y > maxY) mRoom.InvSize.y = maxY; } else if (mDragMode == DragMode.DragPosition) { mRoom.InvPos = new Vec2i(e.X, e.Y) - mDragOffset; if (mRoom.InvPos.x < 0) mRoom.InvPos.x = 0; if (mRoom.InvPos.y < 0) mRoom.InvPos.y = 0; } else if (mDragMode == DragMode.DragBottom) { float newsize = (e.Y - mDragOffset.y - mRoom.InvPos.y + mRoom.ScrollOffset.y); float oldsize = (mRoom.InvSize.y * (50 + mRoom.InvSpacing)) + 5; mRoom.InvScale.y = newsize / oldsize; if (mRoom.InvScale.y > 1.5) mRoom.InvScale.y = 1.5f; if (mRoom.InvScale.y < 0.3) mRoom.InvScale.y = 0.3f; } else if (mDragMode == DragMode.DragRight) { float newsize = (e.X - mDragOffset.x - mRoom.InvPos.x + mRoom.ScrollOffset.x); float oldsize = (mRoom.InvSize.x * (50 + mRoom.InvSpacing)) + 30; mRoom.InvScale.x = newsize / oldsize; if (mRoom.InvScale.x > 1.5) mRoom.InvScale.x = 1.5f; if (mRoom.InvScale.x < 0.3) mRoom.InvScale.x = 0.3f; } } else if (mMode == ViewMode.Specialfx) { if (mDragMode == DragMode.DragCorner) { mDraggingShape.Positions[mShapeIndex] = mMousePos + mRoom.ScrollOffset; if (mDraggingShape.Positions[mShapeIndex].x < 0) mDraggingShape.Positions[mShapeIndex].x = 0; if (mDraggingShape.Positions[mShapeIndex].x > mRoom.Size.x) mDraggingShape.Positions[mShapeIndex].x = mRoom.Size.x; if (mDraggingShape.Positions[mShapeIndex].y < 0) mDraggingShape.Positions[mShapeIndex].y = 0; if (mDraggingShape.Positions[mShapeIndex].y > mRoom.Size.y) mDraggingShape.Positions[mShapeIndex].y = mRoom.Size.y; } else if (mDragMode == DragMode.DragPosition) { Vec2i diff = mMousePos - mDragOffset; for (int i = 0; i < mDraggingShape.Positions.Length; ++i) { mDraggingShape.Positions[i] += diff; if (mDraggingShape.Positions[i].x < 0) correctShapeBoundary(i, new Vec2i(-mDraggingShape.Positions[i].x, 0), ref diff); if (mDraggingShape.Positions[i].x > mRoom.Size.x) correctShapeBoundary(i, new Vec2i(mRoom.Size.x - mDraggingShape.Positions[i].x, 0), ref diff); if (mDraggingShape.Positions[i].y < 0) correctShapeBoundary(i, new Vec2i(0, -mDraggingShape.Positions[i].y), ref diff); if (mDraggingShape.Positions[i].y > mRoom.Size.y) correctShapeBoundary(i, new Vec2i(0, mRoom.Size.y - mDraggingShape.Positions[i].y), ref diff); } mDragOffset = mMousePos; } else if (mDragMode == DragMode.DragBottom) { mDraggingShape.Depth = (e.Y + 5 + mDragOffset.y + mData.WalkGridSize / 2) / mData.WalkGridSize; if (mDraggingShape.Depth < 1) mDraggingShape.Depth = 1; if (mDraggingShape.Depth > mRoom.Size.y / mData.WalkGridSize) mDraggingShape.Depth = mRoom.Size.y / mData.WalkGridSize; } } }
void pictureBox_MouseDown(object sender, MouseEventArgs e) { pictureBox.Focus(); Vec2i center = mData.getHotspot(mState)*mHotspotScale; Vec2i mouse = new Vec2i(e.X, e.Y); if ((mouse - center).length() < 10) { mDraggingOffset = mouse - center; mPictureDragging = 100; return; } string[] pics = mData.getFrame(mState, mFrame); if (pics == null) return; for (int i = pics.Length-1; i >= 0; --i) { if (pics[i] == null) continue; System.Drawing.Bitmap bmp = mData.getImage(pics[i]); Vec2i offset = mData.getFramePartOffset(mState, mFrame, i); if (mouse.x >= offset.x && mouse.x <= offset.x + bmp.Width) { if (mouse.y >= offset.y && mouse.y <= offset.y + bmp.Height) { mDraggingOffset = mouse - offset; mPictureDragging = i + 1; mSelectedPart = i; pictureBox.Invalidate(); if (e.Button == MouseButtons.Right) { Point p = pictureBox.PointToScreen(e.Location); removeMenu.Show(p); } return; } } } mSelectedPart = -1; pictureBox.Invalidate(); }
void RoomDlg_Paint(object sender, PaintEventArgs e) { Bitmap roombmp = new Bitmap(mRoom.Size.x, mRoom.Size.y); Graphics graphics = Graphics.FromImage(roombmp); graphics.TranslateTransform(-mRoom.ScrollOffset.x, -mRoom.ScrollOffset.y); e.Graphics.TranslateTransform(-mRoom.ScrollOffset.x, -mRoom.ScrollOffset.y); if (mRoom.ParallaxBackground.Length > 0) { Bitmap bmp = mData.getImage(mRoom.ParallaxBackground); graphics.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height); } if (mRoom.Background.Length > 0) { Bitmap bmp = mData.getImage(mRoom.Background); graphics.DrawImage(bmp, 0, 0, bmp.Width, bmp.Height); } System.Collections.Generic.LinkedList<System.Collections.Generic.KeyValuePair<int, DrawableObject> > blitqueue = new LinkedList<KeyValuePair<int,DrawableObject>>(); foreach (ObjectInstance obj in mRoom.Objects) { int depth = getDepth(obj); KeyValuePair<int, DrawableObject> pair = new KeyValuePair<int, DrawableObject>(depth, obj); insetQueue(blitqueue, pair); } foreach (CharacterInstance chr in mRoom.Characters) { int depth = getDepth(chr); KeyValuePair<int, DrawableObject> pair = new KeyValuePair<int, DrawableObject>(depth, chr); insetQueue(blitqueue, pair); } Color bordercolor = Color.Red; if (mFramecount < 5 || (mFramecount >= 10 && mFramecount < 15)) bordercolor = Color.Yellow; foreach (System.Collections.Generic.KeyValuePair<int,DrawableObject> pair in blitqueue) { bool isSelected = mControl.SelectedObject == pair.Value; float scale = mRoom.getScale(pair.Value.getPosition()); pair.Value.draw(graphics, mMode == ViewMode.Objects, isSelected ? bordercolor : Color.Red, scale); } ImageAttributes bmpAttributes = new ImageAttributes(); float[][] colorMatrixElements = { new float[] {mRoom.Lighting.R/255.0f, 0, 0, 0, 0}, new float[] {0, mRoom.Lighting.G/255.0f, 0, 0, 0}, new float[] {0, 0, mRoom.Lighting.B/255.0f, 0, 0}, new float[] {0, 0, 0, 1, 0}, new float[] {0, 0, 0, 0, 1} }; ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements); bmpAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); Rectangle screen = new Rectangle(0, 0, mRoom.Size.x, mRoom.Size.y); e.Graphics.DrawImage(roombmp, screen, -mRoom.ScrollOffset.x, -mRoom.ScrollOffset.y, mRoom.Size.x, mRoom.Size.y, GraphicsUnit.Pixel, bmpAttributes); //draw view specific stuff Vec2i mp = mMousePos + mRoom.ScrollOffset; int wmscale = mRoom.DoubleWalkmap ? 2 : 1; int wmx = wmscale * mp.x / mData.WalkGridSize; int wmy = wmscale * mp.y / mData.WalkGridSize; if (wmx < 0) wmx = 0; if (wmy < 0) wmy = 0; if (wmx > mRoom.Walkmap.GetUpperBound(0)) wmx = mRoom.Walkmap.GetUpperBound(0); if (wmy > mRoom.Walkmap.GetUpperBound(1)) wmy = mRoom.Walkmap.GetUpperBound(1); bool wmfree = mRoom.Walkmap[wmx, wmy].isFree; Font f = new Font(Fonts.DefaultFont.FontFamily, 11); if (mMode == ViewMode.Objects) { if (mData.Settings.InfoLine) { string s = String.Format("Position: Room({0}/{1}) Walkmap({2}/{3}){4} Mouse({5}/{6})", mRoom.ScrollOffset.x / mData.WalkGridSize, mRoom.ScrollOffset.y / mData.WalkGridSize, wmx + 1, wmy + 1, wmfree ? 'F' : 'B', mp.x, mp.y); Utilities.drawText(e.Graphics, mRoom.ScrollOffset.x, mRoom.ScrollOffset.y, s, f); } string s2 = "Object:"; DrawableObject drob = getObjectAt(mMousePos+mRoom.ScrollOffset, false); if (drob is ObjectInstance) { ObjectInstance obj = (ObjectInstance)drob; string depth; if (obj.Layer == 0) depth = "Back"; else if (obj.Layer == 1) depth = String.Format("{0}/{1}", getDepth(obj)/2, getDepth(obj)); else depth = "Front"; s2 = String.Format("Object: {0} (PixelPos: {1},{2} Depth: {3})", obj.Name, obj.Position.x, obj.Position.y, depth); } else if (drob is CharacterInstance) { CharacterInstance chr = (CharacterInstance)drob; s2 = String.Format("Object: {0} (WalkmapPos: {1},{2})", chr.Name, wmscale*chr.Position.x/mData.WalkGridSize+1, wmscale*chr.Position.y/mData.WalkGridSize+1); } Utilities.drawText(e.Graphics, mRoom.ScrollOffset.x, mRoom.ScrollOffset.y+f.Height, s2, f); } else if (mMode == ViewMode.Walkmap) { float scale = mRoom.DoubleWalkmap ? 0.5f : 1; SolidBrush b = new SolidBrush(Color.FromArgb(100, Color.Blue)); for (int x = 0; x <= mRoom.Walkmap.GetUpperBound(0); ++x) { for (int y = 0; y <= mRoom.Walkmap.GetUpperBound(1); ++y) { if (!mRoom.Walkmap[x, y].isFree) { e.Graphics.FillRectangle(b, x * mData.WalkGridSize * scale, y * mData.WalkGridSize * scale, mData.WalkGridSize * scale, mData.WalkGridSize * scale); } if (mRoom.Walkmap[x, y].hasScript) { e.Graphics.DrawRectangle(Pens.Black, (x * mData.WalkGridSize + 4) * scale, (y * mData.WalkGridSize + 4) * scale, (mData.WalkGridSize - 8) * scale, (mData.WalkGridSize - 8) * scale); e.Graphics.DrawRectangle(Pens.Yellow, (x * mData.WalkGridSize + 4) * scale + 1, (y * mData.WalkGridSize + 4) * scale + 1, (mData.WalkGridSize - 8) * scale, (mData.WalkGridSize - 8) * scale); } } } //draw grid for (float i = mData.WalkGridSize*scale; i < mRoom.Size.x; i += mData.WalkGridSize*scale) { e.Graphics.DrawLine(Pens.Brown, i, 0, i, mRoom.Size.y); } for (float i = mData.WalkGridSize*scale; i < mRoom.Size.y; i += mData.WalkGridSize*scale) { e.Graphics.DrawLine(Pens.Brown, 0, i, mRoom.Size.x, i); } //draw cursor if (mWalkmapPaintMode >= 0 && mWalkmapPaintMode < 3) { int size = 2 * mWalkmapPaintMode + 1; e.Graphics.DrawEllipse(Pens.Black, ((wmx - mWalkmapPaintMode) * mData.WalkGridSize + 2) * scale, ((wmy - mWalkmapPaintMode) * mData.WalkGridSize + 2) * scale, (size * mData.WalkGridSize - 4) * scale, (size * mData.WalkGridSize - 4) * scale); e.Graphics.DrawEllipse(Pens.LightGray, ((wmx - mWalkmapPaintMode) * mData.WalkGridSize + 1) * scale, ((wmy - mWalkmapPaintMode) * mData.WalkGridSize + 1) * scale, (size * mData.WalkGridSize - 2) * scale, (size * mData.WalkGridSize - 2) * scale); } else { SolidBrush br = null; if (mWalkmapPaintMode == 3) br = new SolidBrush(Color.FromArgb(100, Color.Yellow)); else br = new SolidBrush(Color.FromArgb(100, Color.Red)); e.Graphics.FillRectangle(br, wmx * mData.WalkGridSize * scale, wmy * mData.WalkGridSize * scale, mData.WalkGridSize * scale, mData.WalkGridSize * scale); } //draw information string s = String.Format("{0} ({1},{2})", wmfree ? "Free" : "Blocked", wmx + 1, wmy + 1); Utilities.drawText(e.Graphics, mRoom.ScrollOffset.x, mRoom.ScrollOffset.y, s, f); } else if (mMode == ViewMode.Deepmap) { int y1 = mRoom.Depthmap.x * mData.WalkGridSize; int y2 = mRoom.Depthmap.y * mData.WalkGridSize; SolidBrush blue1 = new SolidBrush(Color.FromArgb(100, Color.Blue)); e.Graphics.FillRectangle(blue1, 0, 0, mData.Settings.Resolution.x * 3, y1); SolidBrush blue2 = new SolidBrush(Color.FromArgb(40, Color.Blue)); e.Graphics.FillRectangle(blue2, 0, y1, mData.Settings.Resolution.x * 3, y2-y1); Pen bluepen = new Pen(Color.Blue, 3.0f); e.Graphics.DrawLine(bluepen, 0, y1, mData.Settings.Resolution.x * 3, y1); e.Graphics.DrawLine(bluepen, 0, y2, mData.Settings.Resolution.x * 3, y2); Utilities.drawText(e.Graphics, mRoom.ScrollOffset.x, y1-f.Height, "Depth 1: "+mRoom.Depthmap.x+" (Pull me)", f); Utilities.drawText(e.Graphics, mRoom.ScrollOffset.x, y2 - f.Height, "Depth 2: " + mRoom.Depthmap.y + " (Pull me)", f); } else if (mMode == ViewMode.Inventory) { if (!mRoom.HasInventory) { Utilities.drawText(e.Graphics, mRoom.ScrollOffset.x, mRoom.ScrollOffset.y, "Draw an inventoryfield into the room.", f); return; } SolidBrush blue = new SolidBrush(Color.FromArgb(50, Color.Blue)); int sizex = (int)(mRoom.InvSize.x * ((50 * mRoom.InvScale.x) + mRoom.InvSpacing) + 30); int sizey = (int)(mRoom.InvSize.y * ((50 * mRoom.InvScale.y) + mRoom.InvSpacing) + 5); e.Graphics.FillRectangle(blue, mRoom.InvPos.x, mRoom.InvPos.y, sizex, sizey); e.Graphics.DrawRectangle(Pens.DarkBlue, mRoom.InvPos.x, mRoom.InvPos.y, sizex, sizey); for (int x = 0; x < mRoom.InvSize.x; ++x) { for (int y = 0; y < mRoom.InvSize.y; ++y) { float posx = x * ((int)(50 * mRoom.InvScale.x) + mRoom.InvSpacing) + 30 + mRoom.InvPos.x; float posy = y * ((int)(50 * mRoom.InvScale.y) + mRoom.InvSpacing) + 5 + mRoom.InvPos.y; e.Graphics.DrawRectangle(Pens.Blue, posx, posy, 50*mRoom.InvScale.x, 48*mRoom.InvScale.y); } } Pen tbp = new Pen(Color.DarkBlue, 5.0f); int ydown = mRoom.InvPos.y+sizey; int xmiddle = mRoom.InvPos.x + sizex / 2; e.Graphics.DrawLine(tbp, xmiddle - 15, ydown - 3, xmiddle + 15, ydown - 3); int ymiddle = mRoom.InvPos.y + sizey / 2; int xright = mRoom.InvPos.x + sizex; e.Graphics.DrawLine(tbp, xright - 3, ymiddle - 15, xright - 3, ymiddle + 15); Point[] points = new Point[4]; points[0] = new Point(xright-11, ydown); points[1] = new Point(xright-5, ydown); points[2] = new Point(xright, ydown - 5); points[3] = new Point(xright, ydown - 11); LinearGradientBrush lgb = new LinearGradientBrush(new Point(xright - 8, ydown), new Point(xright, ydown - 8), Color.DarkBlue, Color.Blue); e.Graphics.FillPolygon(lgb, points); string s = String.Format("Inventory field: {0}x{1} fields", mRoom.InvSize.x, mRoom.InvSize.y); Utilities.drawText(e.Graphics, mRoom.ScrollOffset.x, mRoom.ScrollOffset.y, s, f); } else if (mMode == ViewMode.Specialfx) { for (int coloridx = 0; coloridx < mRoom.FXShapes.Count; ++coloridx) { FxShape shape = (FxShape)mRoom.FXShapes[coloridx]; if (!shape.Active) continue; Color basecol = Color.Black; switch (coloridx) { case 2: basecol = Color.Red; break; case 1: basecol = Color.Green; break; case 0: basecol = Color.Blue; break; } SolidBrush b = new SolidBrush(Color.FromArgb(75, basecol)); GraphicsPath path = new GraphicsPath(); for (int i = 0; i < shape.Positions.Length - 1; ++i) { path.AddLine(shape.Positions[i].x, shape.Positions[i].y, shape.Positions[i + 1].x, shape.Positions[i + 1].y); } path.AddLine(shape.Positions[shape.Positions.Length - 1].x, shape.Positions[shape.Positions.Length - 1].y, shape.Positions[0].x, shape.Positions[0].y); e.Graphics.FillPath(b, path); Pen p = new Pen(basecol); e.Graphics.DrawPath(p, path); Vec2i center = new Vec2i(); for (int i = 0; i < shape.Positions.Length; ++i) { Utilities.drawCircle(e.Graphics, p, 4, shape.Positions[i]); center += shape.Positions[i]; } center /= shape.Positions.Length; Utilities.drawCrosshair(e.Graphics, center, basecol, 1.0f); string s = ""; if (shape.Effect == FxShape.FxEffect.WALL_MIRROR) { Utilities.drawDepthHandle(e.Graphics, mData, center, shape.Depth + 0.5f, basecol); s = "Wall-Mirror"; } else if (shape.Effect == FxShape.FxEffect.FLOOR_MIRROR) s = "Floor-Mirror"; else if (shape.Effect == FxShape.FxEffect.PARTICLE_BARRIER) s = "Particle-Barrier"; Utilities.drawText(e.Graphics, shape.Positions[0].x, shape.Positions[0].y, s, f); } } }
void updateStateValues(int oldstate) { if (mData == null) return; fps.Value = mData.getFPSDivider(mState); Vec2i newsize = mData.getSize(mState) * mHotspotScale; Vec2i oldsize = new Vec2i(pictureBox.Size.Width, pictureBox.Size.Height); if (newsize != oldsize) { PictureBoxSize = new Size(newsize.x, newsize.y); } if (StateChanged != null) StateChanged(this, new StateEventArgs(oldstate, mState)); }
public abstract bool isHit(Vec2i pos);