Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fullscreen
#1
Author: Robin
Difficulty: Requires ability to understand.

This tutorial will allow user's to be able to choose from several options, including windowed, to make the game more suitable for them.

User configuration is really a good thing to add in.

For example, in Naruto Realm Beta, user's can choose which effects to add to text, they can choose font face, font size, resolution and can also enter optional details about themselves, for other people to see and also which way they would like to play music. eg. FMod or Mirage Default.

Now, because this is being made for a Vanilla MSE Build 1, and we are only adding in one option, I will add it into frmChars. I would suggest having an option menu for people when they open the client instead, though.

Now, add these items into frmChars:

Syn: Type | Name | Details

Combo | cmbFulllscreen | Enabled = false. List = 640x480, 800x600, 1024x768, 1280x1024. Type = Dropdown List.
Option | optFullscreen | Value = false
Option | optWindow | Value = true

Now we want it so that when people select Windowed, the combo box becomes disabled, and then enabled when Fullscreen is selected, so...

Add this code into frmChars:

Code:
Private Sub optFullscreen_Click()
cmbFullscreen.Enabled = True
End Sub

Private Sub optWindow_Click()
cmbFullscreen.Enabled = False
End Sub

Private Sub Form_Load()
cmbFullscreen.ListIndex = 0
End Sub

Goto modDirectX, delete:

Code:
' Indicate windows mode application
Call DD.SetCooperativeLevel(frmMirage.hWnd, DDSCL_NORMAL)

and replace with this:

Code:
If frmChars.optFullscreen.Value = True Then
    
        Select Case frmChars.cmbFullscreen.ListIndex
            Case 0
                If Screen.Width  640 And Screen.Height  480 Then
                    Call DD.SetDisplayMode("640", "480", ColourDisplay, 0, DDSDM_DEFAULT)
                End If
            Case 1
                If Screen.Width  800 And Screen.Height  600 Then
                    Call DD.SetDisplayMode("800", "600", ColourDisplay, 0, DDSDM_DEFAULT)
                End If
            Case 2
                If Screen.Width  1024 And Screen.Height  768 Then
                    Call DD.SetDisplayMode("1024", "768", ColourDisplay, 0, DDSDM_DEFAULT)
                End If
            Case 3
                If Screen.Width  1280 And Screen.Height  1024 Then
                    Call DD.SetDisplayMode("1280", "768", ColourDisplay, 0, DDSDM_DEFAULT)
                End If
        End Select
        
        Call DD.SetCooperativeLevel(frmMirage.hWnd, DDSCL_EXCLUSIVE Or DDSCL_FULLSCREEN Or DDSCL_ALLOWMODEX)
        
    ElseIf frmChars.optWindow.Value = True Then
        
        ChangeBorderStyle frmMirage, 2
        frmMirage.Caption = GAME_NAME 'or w/e caption you want
        Call DD.SetCooperativeLevel(frmMirage.hWnd, DDSCL_NORMAL)
        
    End If

What this does is finds which options they selected, and set the display mod accordingly. Then, if it is fullscreen, the cooperative level in frmMirage is set to fullscreen mode(?). If not, then we add a border into frmMirage, re-do the caption, then set the cooperative level to that of just normal(?).

Either create a new module and put this in, or add to another module (I had it in modGeneral. Don't think that exists in Vanilla Mirage)

Code:
Public Sub ChangeBorderStyle(TheForm As Form, Style As Byte)
'code taken from GodSendDeaths post on www.miragesource.com/forums
Dim bToggleStyle As Boolean, bToggleExStyle As Boolean, cStyle As Byte
  
    'This makes sure the selected style is within acceptable range
    If Style > 5 Or Style < 0 Then Style = TheForm.BorderStyle
  
    cStyle = TheForm.BorderStyle
    TheForm.BorderStyle = Style
  
    'Checks the current BorderStyle and changes the variables to comply with selected style
    If Style = 0 Then
        'Don't know yet >_>...
        bToggleStyle = False
        bToggleExStyle = False
    ElseIf Style = 1 Then
        If cStyle = 2 Then
            bToggleStyle = True
        ElseIf cStyle = 3 Then
            bToggleStyle = False
        ElseIf cStyle = 4 Then
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = True
            bToggleExStyle = True
        End If
    ElseIf Style = 2 Then
        If cStyle = 1 Then
            bToggleStyle = True
            bToggleExStyle = False
        ElseIf cStyle = 3 Then
            bToggleStyle = True
        ElseIf cStyle = 4 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = False
            bToggleExStyle = True
        End If
    ElseIf Style = 3 Then
        If cStyle = 1 Then
            bToggleStyle = False
        ElseIf cStyle = 2 Then
            bToggleStyle = True
        ElseIf cStyle = 4 Then
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = True
            bToggleExStyle = True
        End If
    ElseIf Style = 4 Then
        If cStyle = 1 Then
            bToggleExStyle = True
        ElseIf cStyle = 2 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 3 Then
            bToggleExStyle = True
        ElseIf cStyle = 5 Then
            bToggleStyle = True
            bToggleExStyle = False
        End If
    Else
        If cStyle = 1 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 2 Then
            bToggleExStyle = True
        ElseIf cStyle = 3 Then
            bToggleStyle = True
            bToggleExStyle = True
        ElseIf cStyle = 4 Then
            bToggleStyle = True
            bToggleExStyle = False
        End If
    End If
  
    If bToggleStyle Then 'Toggles between Fixed and Sizeable
        Call SetWindowLong(TheForm.hWnd, GWL_STYLE, GetWindowLong(TheForm.hWnd, GWL_STYLE) Xor (WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX))
    End If
  
    If bToggleExStyle Then 'Toggles between ToolWindow and Regular Window
        Call SetWindowLong(TheForm.hWnd, GWL_EXSTYLE, GetWindowLong(TheForm.hWnd, GWL_EXSTYLE) Xor WS_EX_TOOLWINDOW)
    End If

    Call SetWindowPos(TheForm.hWnd, 0&, 0&, 0&, 0&, 0&, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOZORDER Or SWP_FRAMECHANGED)
End Sub

I found that in these forums, posted by GSD. I think it may be in Tutorial Request, or general or something. Anyway, someone asked for some code to change the borderstyle, and I took it.

Now add this sub somewhere. Again, I had it in modGeneral.

Code:
Public Sub Getwindowcolours()
    Dim hdesktopwnd As Long, hdccaps As Long
    
    'Get the desktop hwnd
    hdesktopwnd = GetDesktopWindow()
    'Get the DC
    hdccaps = GetDC(hdesktopwnd)
    'Get the number of colours from the DC
    ColourDisplay = GetDeviceCaps(hdccaps, 12)
    'Release the DC
    Call ReleaseDC(hdesktopwnd, hdccaps)
End Sub

This is a sub which get's the desktop hwnd, get's the DC, then, finds the number of colours. We then release the DC and now we have the desktop's colour setting's saved.

Add this into modGlobals:

Code:
' Fullscreen
Public ColourDisplay As ColourDepth

For the above code.

I had this code in modEnum, you can add anywhere.

Code:
Public Enum ColourDepth
    High32 = 32
    high24 = 24
    True16 = 16
End Enum

enumerate the colours.

Add these into modConstants

Code:
'for the change form border subroutine
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOZORDER = &H4
Public Const SWP_NOREDRAW = &H8
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_SHOWWINDOW = &H40
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_NOCOPYBITS = &H100
Public Const SWP_NOOWNERZORDER = &H200
Public Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Public Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Public Const HWND_TOP = 0
Public Const HWND_BOTTOM = 1
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const GWL_STYLE As Long = (-16&)
Public Const GWL_EXSTYLE As Long = (-20&)
Public Const WS_THICKFRAME As Long = &H40000
Public Const WS_MINIMIZEBOX As Long = &H20000
Public Const WS_MAXIMIZEBOX As Long = &H10000
Public Const WS_EX_TOOLWINDOW As Long = &H80&

Just some code which came with the border changer.

Add these into modDeclares:

Code:
Public Declare Function SetWindowPos Lib "user32" (ByVal hWnd&, ByVal hWndInsertAfter&, ByVal X&, ByVal Y&, ByVal CX&, ByVal CY&, ByVal wFlags&) As Long
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd&, ByVal nIndex&) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, ByVal dwNewLong&) As Long
Public Declare Function GetDesktopWindow Lib "user32" () As Long
Public Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long

Again, came with the border change code.

And finally, goto frmMirage and change borderstyle to:

Code:
0 - None

Obviously, GSD or whoever didn't know how to set the border style to 0, so we have to change frmMirage from 0 to something else. In this case, 2 - Sizable.

You should now have working fullscreen support.

It does look very rubbish with the default maps, but I am adding in scrolling maps into my client, which work in all resolutions.

Players can choose which resolution they want. If you want, you can change it so people choose their own colour quality. I simply added some code which get's the desktop's colour quality and uses that, for compatability reasons.

If you are really lazy, or not too confident programming, you can just as easily change it to a set resolution.

This is probably not the best way to go about things, but it works fine on both Naruto Realm and my SPRPG, Wind's Whisper.

Oh, by the way. This will look pretty bad with the default style of GUI (eg. Having the map in a box with pictures around it) and I would suggest having a small GUI blted on screen, or simply non at all. With Inventory, Spells, Shops and the such blted on screen to make your game look more professional.

Have Fun_^

P.S. No other forms will be able to be loaded. If you add this in you must convert frmTrade, frmTraining and all other external forms to either picture boxes, or to Blted objects, like I did. Having them blted will allow for cool alphablending shizzle like in Naruto Realm Beta Smile

~Kite
Reply
#2
How could i blit it and make it alphablend?
Help Please. Thanks ^-^
Reply
#3
It takes a lot of coding, but what you want to do is get rid of all the picture boxes, list etc. and have all the game blted. Instead of having all the forms and stuff. Ugly :?

I can't really just tell you what to do. You have to do it for yourself.

But, instead of using BltFast, you can grab the DC's of the surface's and use BitBlt, which many people have created Alpha-Blending functions for. Smile
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#4
Real quick question, is this all Client side or does some of it branch into Server Side cuz theres only a mod general on server side in MSE.
Reply
#5
It's all client side. If you read through it you would notice that I said you could put them anywhere, but I also said that I put them in modGeneral, which, as you said does not yet exist in MSE.

Of course... you could just add one in.

~Kite
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#6
I did but I also noticed that you were correct, that you have to change the style of the thingy from having multiple forms. Currently trying to figure out how to change it (but of course I'm clueless on it... freaking bliting)
Reply
#7
As soon as you learn to blt, send packets and learn basic arithmetic... game creation is quite easy xD
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#8
I'm learning the packets but the bliting is over my head for the time being.
Reply
#9
Quote:But, instead of using BltFast, you can grab the DC's of the surface's and use BitBlt, which many people have created Alpha-Blending functions for.

Watch out, though - using this is really going to boost up the system requirements of your game. Alphablending through DirectDraw is quite slow, and even slower through BitBlt.
Reply
#10
Yep, if you want it simply, do it the way dave said, but be careful, it can get strange results with certain colours lol I tryed using it so I could have day/night (This was ages ago). Maybe i'm mistaken and it wasnt srcAnd


Actually, I made an app awhile ago to show how each type looks when blted over different backgrounds. You can get some strange effects when combining them Big Grin
Reply
#11
Alphablending works fine if you add some options client side.

also, using it sparingly (for Inventory, maybe a little background to where you are typing) then it works wonders.

The options will be something like this:

High (full alphablending... slow(ish) on older systems)
Low (way dave said)
None (just goes back to bltFast)

This means people who can play HL2 with full setting's get some nice effects, and those people who struggle to run Runescape get some... well... they get to play the game.

~Kite
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#12
Kite Wrote:As soon as you learn to blt, send packets and learn basic arithmetic... game creation is quite easy xD

How'd you learn how to blit?
Reply
#13
@up Messing with it


@kite:offtopic I need the updated version of Windwisper xd
Reply
#14
Heheh ok. Come on MSN then.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)