Quantcast

Jump to content

» «
Photo

Cleo User Interface [How To]

4 replies to this topic
Manfred Von Karma
  • Manfred Von Karma

    Trick ( ͡ ͜ʖ ͡)

  • Members
  • Joined: 16 Jun 2009
  • None

#1

Posted 14 October 2012 - 05:16 PM

Hi There , today i'm gonna show you the way to include a custom User Interface into GTA:SA via coding ...
So here are the steps to procceed with :


1. We will collect first some images from Google that are related to our theme of the project , in my case , i chose " Hitman 2 ".

2.Then , we will create a new TXD dictionary that will hold the pictures as textures for the game.

3.And the finale step will be of course Coding the script , wich will be in this case a MissionPack (MPACK)



So lets begin ...


______________________________________________________________________________

Before you begin
______________________________________________________________________________


You will need to have these tools : Sanny Builder ; CLEO 4 ; TXD Workshop .

______________________________________________________________________________

Downloading the pictures
______________________________________________________________________________



We will need for this Hitman 2 UI :

1. A cursor icon
2. Some cool hitman background
3. Menu text ( Start Game , Load Game ...) wich can be done by urself without download ...

Cursor ; Background

user posted image ; http://www.zastavki...._2_001426_1.jpg



Save your pictures at your desktop , rename the cursor picture "Cursor" and the Background "Menu" , Note that the pictures should either be one of the following formats : BMP , PNG or TGA , if not then convert them .
______________________________________________________________________________

Setting up the TXD file
______________________________________________________________________________

Using Txd workshop 4.5 open a txd file that u find at /Models/Txd folder , any one , it doesn't matter ... then Click >> File >> Save as >> and name the new file Hitman.txd , click Save .
Now Close the txd file and open Hitman.txd , then delete all the images that you find in it , and start sliding the ones that you downloaded ( Cursor , background ...) on top of the Software ... now you should see you pics added in the list , Compress them by clicking on Image >> Compress All .
Save the TXD

______________________________________________________________________________

Coding
______________________________________________________________________________


Now its coding time , the file that i attached with the topic contains he MPACK folder , put it at GTA SA USER FILES /

Here i 'll explain why i did this and that ...

I created 3 threads : Load , Menu and Check .

The "Load" Thread will be used to load your models that you'll need for your missions , we dont need any models in our UI ...

Menu will hold our script of the User Interface .

Check will be used for loop .


_____________________

thread 'Load'
_____________________

CODE
:Load
thread 'Load'
wait 0
end_thread  


Empty as we dont need any models ...

_____________________

thread 'Menu'
_____________________

CODE
:Menu
thread 'Menu'
wait 0
$GUI = 0
0390: load_txd_dictionary 'hitman'
038F: load_texture "cursor" as 1 // Load dictionary with 0390 first  
038F: load_texture "menu" as 2 // Load dictionary with 0390 first
038F: load_texture "none" as 3 // Load dictionary with 0390 first  
038F: load_texture "selec" as 4 // Load dictionary with 0390 first
0A8C: write_memory 0xBA6745 size 1 value 0 virtual_protect 0
03F0: enable_text_draw 1
$x = 320.0
$y = 224.0
$sl == 3
Player.CanMove($PLAYER_CHAR,0)
0826: enable_hud 0
0581: enable_radar 0
fade 1 800
$GUI = 1
:Menu
wait 0
if and
$sl == 4
0AB0:  key_pressed 1
then
jump @StartGame
else
0A4A: store_joystick_X_offset_to 0@ Y_offset_to 1@
0059: $x += 0@ // (float)
0059: $y += 1@ // (float)
03E3: set_texture_to_be_drawn_antialiased 1
038D: draw_texture 2 position 320.0 224.0 size 640.0 448.0 RGBA 255 255 255 255
038D: draw_texture $sl position 100.0 210.0 size 100.0 25.0 RGBA 255 255 255 255
038D: draw_texture 1 position $x $y size 20.0 20.0 RGBA 255 255 255 255
end
jump @Menu



:StartGame
wait 0
fade 0 0
wait 500
0391: release_txd_dictionary
Player.CanMove($PLAYER_CHAR,1)
0A8C: write_memory 0xBA6745 size 1 value 1 virtual_protect 0  
Audiostream.PerformAction($rollo,STOP)
$GUI = 0
01B2: give_actor $PLAYER_ACTOR weapon 23 ammo 100 // Load the weapon model before using this
01B2: give_actor $PLAYER_ACTOR weapon 29 ammo 100 // Load the weapon model before using this
wait 1000
fade 1 500
end_thread  



QUOTE
$GUI = 0
$x = 320.0
$y = 224.0
$sl == 3

Its a variable that i declared that will let the game to check if the menu is active or not : $GUI = 1 means Menu is shown , 0 means not shown. $x and $y reffers to the position of the Cursor , $sl ( selected ) will be used at the Check thread to see if the cursor is on the "Start Game" if true , $sl becomes 4 ( Start game turns red ) if not , $sl is 3 ( Start game is grey , not selected )


QUOTE
0390: load_txd_dictionary 'hitman'
038F: load_texture "cursor" as 1 // Load dictionary with 0390 first 
038F: load_texture "menu" as 2 // Load dictionary with 0390 first
038F: load_texture "none" as 3 // Load dictionary with 0390 first 
038F: load_texture "selec" as 4 // Load dictionary with 0390 first

Loads the Hitman.tx that we've made earlier along with the 4 textures


QUOTE
03F0: enable_text_draw 1

We will start to draw on the screen , so we need this .

QUOTE

if and
$sl == 4
0AB0:  key_pressed 1
then
jump @StartGame


As you know the Menu thread and the Check thread are running simultaneously , they are cooperating , this Check ( if and ) will see if the cursor is on "Start game" ( if you habe selected it ) and if you pressed it ( key pressed 1 means you pressed Left Mouse Button ) then the Game starts . ( jump@ startgame )



CODE
else
0A4A: store_joystick_X_offset_to 0@ Y_offset_to 1@
0059: $x += 0@ // (float)
0059: $y += 1@ // (float)
03E3: set_texture_to_be_drawn_antialiased 1
038D: draw_texture 2 position 320.0 224.0 size 640.0 448.0 RGBA 255 255 255 255
038D: draw_texture $sl position 100.0 210.0 size 100.0 25.0 RGBA 255 255 255 255
038D: draw_texture 1 position $x $y size 20.0 20.0 RGBA 255 255 255 255
end
jump @Menu


If you didn't press Start Game , then the script continues updating the Cursor's positions , notice that
: 0A4A: store_joystick_X_offset_to 0@ Y_offset_to 1@ does not store the actual position of the cursor , instead it just checks within you move your mouse left ( negative float ) or right ( positive float ) up ( positive float ) or down ( negative float ) , so if you dont move your mouse , the value becomes 0.0 , therefore , i used the :
0059: $x += 0@ // (float)
0059: $y += 1@ // (float)
And it turned out that it just fits perfectly , pure luck ...

______________________________________________________________________________

Prefiew
______________________________________________________________________________







______________________________________________________________________________

Download
______________________________________________________________________________



Click here

LINK/2012
  • LINK/2012

    LIVIN' IN CODE

  • Feroci Racing
  • Joined: 30 Jan 2011
  • Brazil

#2

Posted 14 October 2012 - 06:47 PM

Guy, fix those global variables. Don't use global variables in CLEO.

Michael-Knight1
  • Michael-Knight1

    Never Give UP

  • Members
  • Joined: 08 Jul 2012

#3

Posted 14 October 2012 - 07:03 PM

dude Use end custom thread in cleo cryani.gif

ZAZ
  • ZAZ

    Kernlochbohrer

  • Members
  • Joined: 10 Jan 2005
  • European-Union

#4

Posted 14 October 2012 - 07:36 PM

QUOTE (Link2012 @ Sunday, Oct 14 2012, 19:47)
Guy, fix those global variables. Don't use global variables in CLEO.

QUOTE (Michael-Knight1 @ Sunday, Oct 14 2012, 20:03)
dude Use end custom thread in cleo  cryani.gif

He posted codes for MPACK, but yes, locals are always better if possible
use 0A93: end_custom_thread in cleoscripts
use end_thread in main.scm

Deji
  • Deji

    Coding like a Rockstar!

  • Feroci Racing
  • Joined: 24 Dec 2007
  • None

#5

Posted 15 October 2012 - 02:04 AM

He's indecisive. The topic says "Cleo User Interface", yet his examples are written under the premise that they're MPACK's.

I can't believe this was moved to tutorials tounge.gif




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users