Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Map name drawing problem


erkro1
 Share

Recommended Posts

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 Sub
errorhandler:
    HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Link to comment
Share on other sites

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

im a beginner but one way…

```
For i = 1 To Len(Map.Name)
If Mid$(text, i, 1) = " " Then count
= count + 1
Next

```
```
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

[![](http://filehost.worldlifewarfare.com/pics/33393d5c85ece51dce150d060ed37cbd.bmp)](http://filehost.worldlifewarfare.com/#33393d5c85ece51dce150d060ed37cbd.bmp)

Code:
```
Public Sub UpdateDrawMapName()
Dim MapName As String
Dim 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 Sub
errorhandler:
    HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
Link to comment
Share on other sites

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 Sub
errorhandler:
    HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
Link to comment
Share on other sites

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

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 Sub
errorhandler:
    HandleError "UpdateDrawMapName", "modGameLogic", Err.number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

```
Link to comment
Share on other sites

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

@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

@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

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

@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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...