erkro1 Posted March 10, 2012 Author Share Posted March 10, 2012 So I have some kind of problem with the map name drawing, I've changed it so it displays the map name at the right side instead of in the middle, but when map names are large then it doesn't calculate it right.[![](http://www.freemmorpgmaker.com/files/imagehost/pics/e6b7dd545f1dde25d02cc3ae02c1e738.bmp)](http://www.freemmorpgmaker.com/files/imagehost/#e6b7dd545f1dde25d02cc3ae02c1e738.bmp)The code:```Public Sub UpdateDrawMapName()Dim MapName As String ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler MapName = Trim$(Map.Name) If frmMain.Picture1.Visible = False Then DrawMapNameX = Camera.Right - Len(MapName) * 8 Else DrawMapNameX = Camera.Right - Len(MapName) * 8 - 100 End If DrawMapNameY = Camera.top + 1 Select Case Map.Moral Case MAP_MORAL_NONE DrawMapNameColor = QBColor(BrightRed) Case MAP_MORAL_SAFE DrawMapNameColor = QBColor(White) Case MAP_MORAL_HOUSE DrawMapNameColor = QBColor(Yellow) Case MAP_MORAL_BUYABLE DrawMapNameColor = QBColor(Grey) Case Else DrawMapNameColor = QBColor(White) End Select ' Error handler Exit Suberrorhandler: HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub``` Link to comment Share on other sites More sharing options...
erkro1 Posted March 17, 2012 Author Share Posted March 17, 2012 I still need help with this problem. Link to comment Share on other sites More sharing options...
Sicarii Posted March 17, 2012 Share Posted March 17, 2012 i wont be in front of vb until tonight but doesnt it have to do with the DrawMapNameX bit (remove the '-100')? Edit: err with frmMain.Picture1.Visible being false/true…hence making the change. Link to comment Share on other sites More sharing options...
erkro1 Posted March 17, 2012 Author Share Posted March 17, 2012 No, thats for the ammo window, I've made it so it checks if its active and else move the text to the left. Link to comment Share on other sites More sharing options...
Sicarii Posted March 17, 2012 Share Posted March 17, 2012 ahhh…so it looks like the extra space is exactly two spaces....the amount of spaces inbetween words in your map title. Id bet if you made it mitserayarmybase (all one word) itd look fine...if so then you need to code to accomodate spaces within title Link to comment Share on other sites More sharing options...
erkro1 Posted March 17, 2012 Author Share Posted March 17, 2012 You're right, any idea on how I can fix this, I'm very bad with the blting shit. :P Link to comment Share on other sites More sharing options...
Sicarii Posted March 17, 2012 Share Posted March 17, 2012 im a beginner but one way…```For i = 1 To Len(Map.Name)If Mid$(text, i, 1) = " " Then count= count + 1Next``````DrawMapNameX = Camera.Right - (Len(MapName)-count) * 8```just off top of my head….edit nvm that would prob just cut off the se in base...ill shut up now since im on my phone and not at a pc sorry Link to comment Share on other sites More sharing options...
erkro1 Posted March 17, 2012 Author Share Posted March 17, 2012 [![](http://filehost.worldlifewarfare.com/pics/33393d5c85ece51dce150d060ed37cbd.bmp)](http://filehost.worldlifewarfare.com/#33393d5c85ece51dce150d060ed37cbd.bmp)Code:```Public Sub UpdateDrawMapName()Dim MapName As StringDim I, Count As Long ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler MapName = Trim$(Map.Name) For I = 1 To Len(Map.Name) If Mid$(MapName, I, 1) = " " Then Count = Count + 1 Next If frmMain.Picture1.Visible = False Then DrawMapNameX = Camera.Right - (Len(MapName) - Count) * 8 Else DrawMapNameX = Camera.Right - (Len(MapName) - Count) * 8 - 100 End If DrawMapNameY = Camera.top + 1 Select Case Map.Moral Case MAP_MORAL_NONE DrawMapNameColor = QBColor(BrightRed) Case MAP_MORAL_SAFE DrawMapNameColor = QBColor(White) Case MAP_MORAL_HOUSE DrawMapNameColor = QBColor(Yellow) Case MAP_MORAL_BUYABLE DrawMapNameColor = QBColor(Grey) Case Else DrawMapNameColor = QBColor(White) End Select ' Error handler Exit Suberrorhandler: HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub``` Link to comment Share on other sites More sharing options...
Sicarii Posted March 17, 2012 Share Posted March 17, 2012 maybe try changing the static 8 to a different number? Link to comment Share on other sites More sharing options...
erkro1 Posted March 17, 2012 Author Share Posted March 17, 2012 @Sicarii:> maybe try changing the static 8 to a different number?With 8 the text is the closest to the position where it should be. Link to comment Share on other sites More sharing options...
Sicarii Posted March 17, 2012 Share Posted March 17, 2012 but not when there are spaces in map name…you could do an if spaces in name then make it be x else be the 8 Link to comment Share on other sites More sharing options...
erkro1 Posted March 17, 2012 Author Share Posted March 17, 2012 @Sicarii:> but not when there are spaces in map name…you could do an if spaces in name then make it be x else be the 8What do you mean with x? Link to comment Share on other sites More sharing options...
Sicarii Posted March 17, 2012 Share Posted March 17, 2012 changing 8 to a dif number Link to comment Share on other sites More sharing options...
erkro1 Posted March 17, 2012 Author Share Posted March 17, 2012 @Sicarii:> changing 8 to a dif numberI did, I tried some different but it works best with 8. Link to comment Share on other sites More sharing options...
Ruins of Hell Posted March 18, 2012 Share Posted March 18, 2012 Try this:```Public Sub UpdateDrawMapName()Dim MapName As String ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler MapName = Trim$(Map.Name) If frmMain.Picture1.Visible = False Then DrawMapNameX = Camera.Right - getWidth(TexthDC, Trim$(Map.Name)) Else DrawMapNameX = Camera.Right - getWidth(TexthDC, Trim$(Map.Name)) - 100 End If DrawMapNameY = Camera.top + 1 Select Case Map.Moral Case MAP_MORAL_NONE DrawMapNameColor = QBColor(BrightRed) Case MAP_MORAL_SAFE DrawMapNameColor = QBColor(White) Case MAP_MORAL_HOUSE DrawMapNameColor = QBColor(Yellow) Case MAP_MORAL_BUYABLE DrawMapNameColor = QBColor(Grey) Case Else DrawMapNameColor = QBColor(White) End Select ' Error handler Exit Suberrorhandler: HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub``` Link to comment Share on other sites More sharing options...
erkro1 Posted March 19, 2012 Author Share Posted March 19, 2012 That makes it even worser:[![](http://filehost.worldlifewarfare.com/pics/d6b5b5c2403f7a3686804c2a6aa36dca.bmp)](http://filehost.worldlifewarfare.com/#d6b5b5c2403f7a3686804c2a6aa36dca.bmp)Thanks for your reply anyway. ;) Link to comment Share on other sites More sharing options...
Ruins of Hell Posted March 19, 2012 Share Posted March 19, 2012 Hmm… that's weird. getWidth is the default Eclipse Origins text function, but oddly enough, it seems to not return the actual width but half of it. I guess it is because it is only used for centering. Oh well, shows you not to trust functions without actually checking what they do.On a related note, when you take these screenshots, can you take them on one map all the time so we can see the difference?Anyway, this might work:```Public Sub UpdateDrawMapName()Dim MapName As String ' If debug mode, handle error then exit out If Options.Debug = 1 Then On Error GoTo errorhandler MapName = Trim$(Map.Name) If frmMain.Picture1.Visible = False Then DrawMapNameX = Camera.Right - frmMain.TextWidth(MapName) Else DrawMapNameX = Camera.Right - frmMain.TextWidth(MapName) - 100 End If DrawMapNameY = Camera.top + 1 Select Case Map.Moral Case MAP_MORAL_NONE DrawMapNameColor = QBColor(BrightRed) Case MAP_MORAL_SAFE DrawMapNameColor = QBColor(White) Case MAP_MORAL_HOUSE DrawMapNameColor = QBColor(Yellow) Case MAP_MORAL_BUYABLE DrawMapNameColor = QBColor(Grey) Case Else DrawMapNameColor = QBColor(White) End Select ' Error handler Exit Suberrorhandler: HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext Err.Clear Exit SubEnd Sub``` Link to comment Share on other sites More sharing options...
erkro1 Posted March 20, 2012 Author Share Posted March 20, 2012 Still not working, but I've made screenshots for both Supreme City (2nd picture) and Federation Army Camp:[![](http://filehost.worldlifewarfare.com/pics/c0e270a3c81950100905104279149f9b.bmp)](http://filehost.worldlifewarfare.com/#c0e270a3c81950100905104279149f9b.bmp) Link to comment Share on other sites More sharing options...
PD Posted March 20, 2012 Share Posted March 20, 2012 How about changing the '- 100' bit to see what happens. Link to comment Share on other sites More sharing options...
Ruins of Hell Posted March 20, 2012 Share Posted March 20, 2012 @Zesh:> How about changing the '- 100' bit to see what happens.I think he said that is if the ammo window is open. But I agree with your idea, it seems that the letters are always a static number of pixels away. Fooling around by adding a number at the end might work. However, I'm not really sure why it doesn't work anyway.@Erwin:> Still not working, but I've made screenshots for both Supreme City (2nd picture) and Federation Army Camp:Do stuff like /loc appear at the correct spot (at the very left)? Link to comment Share on other sites More sharing options...
Sicarii Posted March 21, 2012 Share Posted March 21, 2012 ```DrawMapNameX = Camera.Right - (Len(Trim$((Map.Name)))*8)``` Link to comment Share on other sites More sharing options...
erkro1 Posted March 21, 2012 Author Share Posted March 21, 2012 @Soul:> I think he said that is if the ammo window is open. But I agree with your idea, it seems that the letters are always a static number of pixels away. Fooling around by adding a number at the end might work. However, I'm not really sure why it doesn't work anyway.Removing the 100 doesn't make any different.@Soul:> Do stuff like /loc appear at the correct spot (at the very left)?Yes, /loc works correctly.@Sicarii:> ```> DrawMapNameX = Camera.Right - (Len(Trim$((Map.Name)))*8)> > ```Thats the code I was using at the begin. Link to comment Share on other sites More sharing options...
Sicarii Posted March 21, 2012 Share Posted March 21, 2012 i believe it is slightly different from your original post…you will have a space between last letter and map edge but regardless of map name the space is always calculated correctly and equal. Im no math expert but your original post is saying, for example 5 - 2 * 8 where as this says 5 - (2 * 8) which changes the result. Link to comment Share on other sites More sharing options...
erkro1 Posted March 21, 2012 Author Share Posted March 21, 2012 @Sicarii:> i believe it is slightly different from your original post…you will have a space between last letter and map edge but regardless of map name the space is always calculated correctly and equal. Im no math expert but your original post is saiyan, for example 5 - 2 * 8 where as this says 5 - (2 * 8) which changes the result.Aha, now I see that its different, sorry.But I've tried it and same result. :( Link to comment Share on other sites More sharing options...
Sicarii Posted March 21, 2012 Share Posted March 21, 2012 hmmm…I'm out of ideas as it works fine for me that way. Like I said, there will be one space of blankness there but regardless of map name the space is the same. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now