DopeyBiach Posted August 28, 2012 Author Share Posted August 28, 2012 In the DrawNpcName precedure.. How would I go about getting it to center the drawn text.. Here's the annoying bit.. Depending on the NPC's sprite size.. Because bigger sprites text is always drawn on the left..Thank you ^_____^ Link to comment Share on other sites More sharing options...
Growlith1223 Posted August 28, 2012 Share Posted August 28, 2012 TextX = ConvertMapX(MapNpc(Index).x * PIC_X) + MapNpc(Index).XOffset + (PIC_X \ 2) - ((Len(Trim$(Npc(MapNpc(Index).num).Name)) / 2) * 8)This should fix that Link to comment Share on other sites More sharing options...
DopeyBiach Posted August 28, 2012 Author Share Posted August 28, 2012 No, sorry. That doesn't move the text depending on the sprite's size.. That does it depending on the name ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)EDIT: I have an idea, will tell you if it works. Keep the ideas coming until then :]EDIT: It worked. Here's what I did.Added a new object to the NPC Editor.scrlSize and lblSize.The procedure for scrlSize_Change() is as follwoed:```Private Sub scrlSize_Change()' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo ErrorhandlerlblSize.Caption = "Size: " & scrlSize.ValueNpc(EditorIndex).Size = scrlSize.Value' Error handlerExit SubErrorhandler:HandleError "scrlSize_Change", "frmEditor_NPC", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Add this to NpcRec in ModTypes in the Server and Client - Just under 'Level as Long'```Size As Long```Add this to NPCEditorInit in modGameEditors just under '.scrlAnimation.Value = Npc(EditorIndex).Animation'``` If Npc(EditorIndex).Size <= 0 or Npc(EditorIndex).Size > .scrlSize.Max Then .Npc(EditorIndex).Size = 0 .scrlSize.Value = 0 Else .scrlSize.Value = Npc(EditorIndex).Size End If```Add:```Dim CenterShift As Long```Just under 'Dim npcNum as Long'Just under:```Select Case Npc(npcNum).Behaviour Case NPC_BEHAVIOUR_ATTACKONSIGHT color = QBColor(White) Case NPC_BEHAVIOUR_ATTACKWHENATTACKED color = QBColor(Grey) Case NPC_BEHAVIOUR_GUARD color = QBColor(White) Case Else color = QBColor(White)End Select```and above 'Npc = Trim$(Npc(npcNum).Name) add:```If Val(Npc(MapNpc(Index).num).Size) > 0 Then If Val(Npc(MapNpc(Index).num).Size) = 1 Then CenterShift = 0 ElseIf Val(Npc(MapNpc(Index).num).Size) = 2 Then CenterShift = 16 End IfEnd If```Finally replace:```TextX = ConvertMapX(MapNpc(Index).X * PIC_X) + MapNpc(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(Name)))```With:```TextX = ConvertMapX(MapNpc(Index).X * PIC_X) + MapNpc(Index).XOffset + (PIC_X \ 2) - ((Len(Trim$(Npc(MapNpc(Index).num).Name)) / 2) * 8) + CenterShift```Zero, I used that bit of code you gave me aswell to make it work :]..What this does is if the actual sprite's image width (not the entire block, like the transparency around it) is 64px then it centers the name nicely. When the size is set to 2 in the npc editor.. If it's a normal sprite, set it to 1 ^___^I'm sure there was an easier way but meh. 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