Mirage Source http://web.miragesource.net/forums/ |
|
More Editor Optimization http://web.miragesource.net/forums/viewtopic.php?f=210&t=90 |
Page 1 of 1 |
Author: | BigRed [ Fri Jun 02, 2006 4:37 am ] |
Post subject: | More Editor Optimization |
Difficulty: 2/5 = Easy This is an extremely basic optimization. I meant to post this a long time ago, but never got around to it. BitBlt in Mirage is a completely useless function. There is absolutely no need for it, especially since when it is used, it loads pictures that are already loaded into memory, again. Useless and hogs memory. This was made for MSE Build 1, but will work on 3.0.x. All Client Side. Open frmItemEditor. Make the form a little longer and select and delete picItems. Select picPic, and set it's AutoRedraw property to 'True'. Resize the form back to the way it was (Height = 4695) Open frmMirage. Inside of picBack, in the upper left corner, select picBackSelect and delete it. Select picBack and change it's AutoRedraw property to 'True'. Select picSelect and set it's AutoRedraw property to 'True'. Goto Code View. Find: Code: Private Sub picBackSelect_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Call EditorChooseTile(Button, Shift, x, y) End Sub Replace with: Code: Private Sub picBack_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) Call EditorChooseTile(Button, Shift, x, y) End Sub Find: Code: Private Sub picBackSelect_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Call EditorChooseTile(Button, Shift, x, y) End Sub Replace with: Code: Private Sub picBack_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) Call EditorChooseTile(Button, Shift, x, y) End Sub Open frmNPCEditor. Make the form a little longer and select and delete picSprites. Select picSprite, and set it's AutoRedraw property to 'True'. Resize the form back to the way it was (Height = 9375) Open modGameLogic. Find: Code: Public Sub EditorInit() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 07/12/2005 Shannara Added gfx constants. '**************************************************************** SaveMap = Map InEditor = True frmMirage.picMapEditor.Visible = True With frmMirage.picBackSelect .Width = 7 * PIC_X .Height = 255 * PIC_Y .Picture = LoadPicture(App.Path + GFX_PATH + "tiles" + GFX_EXT) End With End Sub Replace with: Code: Public Sub EditorInit() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Changed BitBlt to DX7 '* 07/12/2005 Shannara Added gfx constants. '**************************************************************** SaveMap = Map InEditor = True frmMirage.picMapEditor.Visible = True frmMirage.scrlPicture.Max = Int(DDSD_Tile.lHeight / PIC_Y) - 7 With rec .top = 0 .Bottom = frmMirage.picBack.Height .Left = 0 .Right = frmMirage.picBack.Width End With If DD_TileSurf Is Nothing Then Else With rec_pos If frmMirage.scrlPicture.Value = 0 Then .top = 0 Else .top = (frmMirage.scrlPicture.Value * PIC_Y) * 1 End If .Left = 0 .Bottom = .top + (frmMirage.picBack.Height) .Right = frmMirage.picBack.Width End With DD_TileSurf.BltToDC frmMirage.picBack.hdc, rec_pos, rec frmMirage.picBack.Refresh End If End Sub Find: Code: Public Sub EditorChooseTile(Button As Integer, Shift As Integer, x As Single, y As Single) If Button = 1 Then EditorTileX = Int(x / PIC_X) EditorTileY = Int(y / PIC_Y) End If Call BitBlt(frmMirage.picSelect.hdc, 0, 0, PIC_X, PIC_Y, frmMirage.picBackSelect.hdc, EditorTileX * PIC_X, EditorTileY * PIC_Y, SRCCOPY) End Sub Replace with: Code: Public Sub EditorChooseTile(Button As Integer, Shift As Integer, x As Single, y As Single) '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Changed BitBlt to DX7 '**************************************************************** If Button = 1 Then EditorTileX = Int(x / PIC_X) EditorTileY = Int(y / PIC_Y) + frmMirage.scrlPicture.Value End If With rec_pos .top = EditorTileY * PIC_Y .Bottom = .top + PIC_Y .Left = EditorTileX * PIC_X .Right = .Left + PIC_X End With With rec .top = 0 .Bottom = PIC_Y .Left = 0 .Right = PIC_X End With If DD_TileSurf Is Nothing Then Else DD_TileSurf.BltToDC frmMirage.picSelect.hdc, rec_pos, rec End If frmMirage.picSelect.Refresh End Sub Find: Code: Public Sub EditorTileScroll() frmMirage.picBackSelect.top = (frmMirage.scrlPicture.Value * PIC_Y) * -1 End Sub Replace with: Code: Public Sub EditorTileScroll() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Changed BitBlt to DX7 '**************************************************************** With rec .top = 0 .Bottom = frmMirage.picBack.Height .Left = 0 .Right = frmMirage.picBack.Width End With If DD_TileSurf Is Nothing Then Else With rec_pos If frmMirage.scrlPicture.Value = 0 Then .top = 0 Else .top = (frmMirage.scrlPicture.Value * PIC_Y) * 1 End If .Left = 0 .Bottom = .top + (frmMirage.picBack.Height) .Right = frmMirage.picBack.Width End With DD_TileSurf.BltToDC frmMirage.picBack.hdc, rec_pos, rec frmMirage.picBack.Refresh End If End Sub Find: Code: Public Sub ItemEditorBltItem() Call BitBlt(frmItemEditor.picPic.hdc, 0, 0, PIC_X, PIC_Y, frmItemEditor.picItems.hdc, 0, frmItemEditor.scrlPic.Value * PIC_Y, SRCCOPY) End Sub Replace with: Code: Public Sub ItemEditorBltItem() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Changed BitBlt to DX7 '**************************************************************** With rec .top = frmItemEditor.scrlPic.Value * PIC_Y .Bottom = .top + PIC_Y .Left = 0 .Right = PIC_X End With With rec_pos .top = 0 .Bottom = PIC_Y .Left = 0 .Right = PIC_X End With If DD_ItemSurf Is Nothing Then Else DD_ItemSurf.BltToDC frmItemEditor.picPic.hdc, rec, rec_pos End If frmItemEditor.picPic.Refresh End Sub Find Code: Public Sub ItemEditorInit() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 07/12/2005 Shannara Added gfx constant. '**************************************************************** frmItemEditor.picItems.Picture = LoadPicture(App.Path & GFX_PATH & "items" & GFX_EXT) frmItemEditor.txtName.Text = Trim(Item(EditorIndex).Name) frmItemEditor.scrlPic.Value = Item(EditorIndex).Pic frmItemEditor.cmbType.ListIndex = Item(EditorIndex).Type If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then frmItemEditor.fraEquipment.Visible = True frmItemEditor.scrlDurability.Value = Item(EditorIndex).Data1 frmItemEditor.scrlStrength.Value = Item(EditorIndex).Data2 Else frmItemEditor.fraEquipment.Visible = False End If If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then frmItemEditor.fraVitals.Visible = True frmItemEditor.scrlVitalMod.Value = Item(EditorIndex).Data1 Else frmItemEditor.fraVitals.Visible = False End If If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then frmItemEditor.fraSpell.Visible = True frmItemEditor.scrlSpell.Value = Item(EditorIndex).Data1 Else frmItemEditor.fraSpell.Visible = False End If frmItemEditor.Show vbModal End Sub Replace with: Code: Public Sub ItemEditorInit() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Removed LoadPicture '* 07/12/2005 Shannara Added gfx constant. '**************************************************************** frmItemEditor.txtName.Text = Trim(Item(EditorIndex).Name) frmItemEditor.scrlPic.Value = Item(EditorIndex).Pic frmItemEditor.cmbType.ListIndex = Item(EditorIndex).Type If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then frmItemEditor.fraEquipment.Visible = True frmItemEditor.scrlDurability.Value = Item(EditorIndex).Data1 frmItemEditor.scrlStrength.Value = Item(EditorIndex).Data2 Else frmItemEditor.fraEquipment.Visible = False End If If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then frmItemEditor.fraVitals.Visible = True frmItemEditor.scrlVitalMod.Value = Item(EditorIndex).Data1 Else frmItemEditor.fraVitals.Visible = False End If If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then frmItemEditor.fraSpell.Visible = True frmItemEditor.scrlSpell.Value = Item(EditorIndex).Data1 Else frmItemEditor.fraSpell.Visible = False End If frmItemEditor.Show vbModal End Sub Find: Code: Public Sub NpcEditorInit() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 07/12/2005 Shannara Added gfx constant. '**************************************************************** frmNpcEditor.picSprites.Picture = LoadPicture(App.Path & GFX_PATH & "sprites" & GFX_EXT) frmNpcEditor.txtName.Text = Trim(Npc(EditorIndex).Name) frmNpcEditor.txtAttackSay.Text = Trim(Npc(EditorIndex).AttackSay) frmNpcEditor.scrlSprite.Value = Npc(EditorIndex).Sprite frmNpcEditor.txtSpawnSecs.Text = STR(Npc(EditorIndex).SpawnSecs) frmNpcEditor.cmbBehavior.ListIndex = Npc(EditorIndex).Behavior frmNpcEditor.scrlRange.Value = Npc(EditorIndex).Range frmNpcEditor.txtChance.Text = STR(Npc(EditorIndex).DropChance) frmNpcEditor.scrlNum.Value = Npc(EditorIndex).DropItem frmNpcEditor.scrlValue.Value = Npc(EditorIndex).DropItemValue frmNpcEditor.scrlSTR.Value = Npc(EditorIndex).STR frmNpcEditor.scrlDEF.Value = Npc(EditorIndex).DEF frmNpcEditor.scrlSPEED.Value = Npc(EditorIndex).SPEED frmNpcEditor.scrlMAGI.Value = Npc(EditorIndex).MAGI frmNpcEditor.Show vbModal End Sub Replace with: Code: Public Sub NpcEditorInit() '**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Removed LoadPicture '* 07/12/2005 Shannara Added gfx constant. '**************************************************************** frmNpcEditor.txtName.Text = Trim(Npc(EditorIndex).Name) frmNpcEditor.txtAttackSay.Text = Trim(Npc(EditorIndex).AttackSay) frmNpcEditor.scrlSprite.Value = Npc(EditorIndex).Sprite frmNpcEditor.txtSpawnSecs.Text = STR(Npc(EditorIndex).SpawnSecs) frmNpcEditor.cmbBehavior.ListIndex = Npc(EditorIndex).Behavior frmNpcEditor.scrlRange.Value = Npc(EditorIndex).Range frmNpcEditor.txtChance.Text = STR(Npc(EditorIndex).DropChance) frmNpcEditor.scrlNum.Value = Npc(EditorIndex).DropItem frmNpcEditor.scrlValue.Value = Npc(EditorIndex).DropItemValue frmNpcEditor.scrlSTR.Value = Npc(EditorIndex).STR frmNpcEditor.scrlDEF.Value = Npc(EditorIndex).DEF frmNpcEditor.scrlSPEED.Value = Npc(EditorIndex).SPEED frmNpcEditor.scrlMAGI.Value = Npc(EditorIndex).MAGI frmNpcEditor.Show vbModal End Sub Find: Code: Public Sub NpcEditorBltSprite() Call BitBlt(frmNpcEditor.picSprite.hdc, 0, 0, PIC_X, PIC_Y, frmNpcEditor.picSprites.hdc, 3 * PIC_X, frmNpcEditor.scrlSprite.Value * PIC_Y, SRCCOPY) End Sub Replace with: Code: Public Sub NpcEditorBltSprite()
'**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Changed BitBlt to DX7 '**************************************************************** With rec .top = frmNpcEditor.scrlSprite.Value * PIC_Y .Bottom = .top + PIC_Y .Left = 3 * PIC_X .Right = .Left + PIC_X End With With rec_pos .top = 0 .Bottom = PIC_Y .Left = 0 .Right = PIC_X End With If DD_SpriteSurf Is Nothing Then Else DD_SpriteSurf.BltToDC frmNpcEditor.picSprite.hdc, rec, rec_pos End If frmNpcEditor.picSprite.Refresh End Sub Done. |
Author: | grimsk8ter11 [ Fri Jun 02, 2006 10:48 am ] |
Post subject: | |
nice stuff, always good to see optimizations optimized. |
Author: | Bradyok [ Sun Jun 04, 2006 1:57 am ] |
Post subject: | |
Thanks alot for posting this, it's pretty useful. Also, any idea if this will prevent the error "Cannot create auto redraw image" that some users get? |
Author: | grimsk8ter11 [ Sun Jun 04, 2006 2:07 am ] |
Post subject: | |
post the answer to this in bugs: What exactly do they do when it happens? |
Author: | BigRed [ Sun Jun 04, 2006 3:48 am ] |
Post subject: | |
To be honest. I don't use mirage at all. I just hang around to see if anything good comes up out of it. So, in answer to your question, I've never seen the bug before. |
Author: | Doombringer [ Wed Jun 07, 2006 6:54 pm ] |
Post subject: | |
You forgot to get rid of the loading on "ItemEditorInit" Find the "Public Sub ItemEditorInit()" bit in modGameLogic, and remove the loading pic from the sub so it looks something like this: Code: Public Sub ItemEditorInit()
frmItemEditor.txtName.Text = Trim(Item(EditorIndex).Name) frmItemEditor.scrlPic.Value = Item(EditorIndex).Pic frmItemEditor.cmbType.ListIndex = Item(EditorIndex).Type If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then frmItemEditor.fraEquipment.Visible = True frmItemEditor.scrlDurability.Value = Item(EditorIndex).Data1 frmItemEditor.scrlStrength.Value = Item(EditorIndex).Data2 Else frmItemEditor.fraEquipment.Visible = False End If If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then frmItemEditor.fraVitals.Visible = True frmItemEditor.scrlVitalMod.Value = Item(EditorIndex).Data1 Else frmItemEditor.fraVitals.Visible = False End If If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then frmItemEditor.fraSpell.Visible = True frmItemEditor.scrlSpell.Value = Item(EditorIndex).Data1 Else frmItemEditor.fraSpell.Visible = False End If frmItemEditor.Show vbModal End Sub Hope that helps |
Author: | BigRed [ Wed Jun 07, 2006 10:31 pm ] |
Post subject: | |
Opp, kept thinking I was leaving one out. Edited tutorial above.. |
Author: | James [ Sun Sep 03, 2006 6:44 pm ] |
Post subject: | |
When you use this, you will notice the map editor no longer shows which tile you have selected. Red forgot to keep the part of the code in there, so I have added it. it works fine, just replace Sub EditorChooseTile with the one below. Code: Public Sub EditorChooseTile(Button As Integer, Shift As Integer, x As Single, y As Single)
'**************************************************************** '* WHEN WHO WHAT '* ---- --- ---- '* 06/01/2006 BigRed Changed BitBlt to DX7 '**************************************************************** If Button = 1 Then EditorTileX = Int(x / PIC_X) EditorTileY = Int(y / PIC_Y) + frmMirage.scrlPicture.Value End If With rec_pos .top = EditorTileY * 32 .Bottom = .top + 32 .Left = EditorTileX * 32 .Right = .Left + 32 End With With rec .top = 0 .Bottom = 32 .Left = 0 .Right = 32 End With If DD_TileSurf Is Nothing Then Else DD_TileSurf.BltToDC frmMirage.picBack.hdc, rec_pos, rec End If frmMirage.picSelect.Refresh Call BitBlt(frmMirage.picSelect.hdc, 0, 0, PIC_X, PIC_Y, frmMirage.picBackSelect.hdc, EditorTileX * PIC_X, EditorTileY * PIC_Y, SRCCOPY) End Sub |
Author: | BigRed [ Tue Sep 05, 2006 12:37 am ] |
Post subject: | |
Oop sorry about that. Somehow I screwed up on the copy & pasting. Anyway, there's only one small change you need to make. It's edited in the first post but here's the change: In EditorChooseTile: Find: Code: DD_TileSurf.BltToDC frmMirage.picBack.hdc, rec_pos, rec and change to Code: DD_TileSurf.BltToDC frmMirage.picSelect.hdc, rec_pos, rec
Btw, I also noticed, in the tutorial I defaulted to 32x32 tiles, I'm going to go through and change that for everyone as well. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |