Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
添加角色属性信息显示功能
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-soft committed Oct 14, 2013
1 parent dc14e94 commit 96ada4f
Showing 1 changed file with 170 additions and 7 deletions.
177 changes: 170 additions & 7 deletions src/game_role_select.c
Expand Up @@ -3,24 +3,35 @@
#include LC_WIDGET_H
#include LC_WINDOW_H
#include LC_BUTTON_H
#include LC_LABEL_H
#include LC_PROGBAR_H

#include "game_control.h"
#include "game_action.h"
#include "game_object.h"
#include "skills/game_skill.h"
#include "game_role_select.h"

#define WINDOWS_SIZE Size(320,240)
#define WINDOWS_SIZE Size(320,300)
#define ROLE_IMAGE_BOX_SIZE Size(100,120)
#define BTN_SIZE Size(80,30)
#define INFO_AREA_SIZE Size(295,135)
#define SKILL_AREA_SIZE Size(295,70)

#define TEXT_NEXT_ROLE L"下个角色"
#define TEXT_PREV_ROLE L"上个角色"
#define TEXT_SELECT_ROLE L"选择该角色"

static LCUI_Widget *window;
static LCUI_Widget *role_image, *role_image_box;
static LCUI_Widget *label_role_name, *label_hp_value;
static LCUI_Widget *btn_prev_role, *btn_next_role, *btn_select_role;
static LCUI_Widget *role_info_text;
static LCUI_Widget *label_punch, *label_kick, *label_defense;
static LCUI_Widget *label_hp, *label_throw, *label_speed;
static LCUI_Widget *progbar_punch, *progbar_kick, *progbar_defense;
static LCUI_Widget *progbar_hp, *progbar_throw, *progbar_speed;
static LCUI_Widget *label_skilllist;
static LCUI_Widget *info_area, *skill_area;

static int current_select_role = 0;

Expand All @@ -37,10 +48,70 @@ static void closebtn_clicked( LCUI_Widget *widget, LCUI_WidgetEvent *unused )
}
}

static void GetSkillName( const char *in_skillname, wchar_t *out_skillname )
{
if(strcmp(in_skillname, SKILLNAME_MACH_A_ATTACK) == 0) {
wcscpy( out_skillname, L"高速拳" );
}
else if(strcmp(in_skillname, SKILLNAME_MACH_B_ATTACK) == 0) {
wcscpy( out_skillname, L"高速踢" );
}
else if(strcmp(in_skillname, SKILLNAME_BIG_ELBOW) == 0) {
wcscpy( out_skillname, L"肘压" );
}
else if(strcmp(in_skillname, SKILLNAME_GUILLOTINE) == 0) {
wcscpy( out_skillname, L"断头台" );
}
else if(strcmp(in_skillname, SKILLNAME_TORNADO_ATTACK) == 0) {
wcscpy( out_skillname, L"龙卷攻击" );
}
else if(strcmp(in_skillname, SKILLNAME_JUMP_SPINKICK) == 0) {
wcscpy( out_skillname, L"高跳旋转落踢" );
}
else if(strcmp(in_skillname, SKILLNAME_BOMBKICK) == 0) {
wcscpy( out_skillname, L"爆裂踢" );
}
else if(strcmp(in_skillname, SKILLNAME_SOLID_DEFENSE) == 0) {
wcscpy( out_skillname, L"磐石防御" );
}
else if(strcmp(in_skillname, SKILLNAME_SPINHIT) == 0) {
wcscpy( out_skillname, L"自旋击" );
}
else if(strcmp(in_skillname, SKILLNAME_MACH_STOMP) == 0) {
wcscpy( out_skillname, L"自旋击" );
} else {
wcscpy( out_skillname, L"(未知)" );
}
}

/** 选择角色 */
void RoleSelectBox_SetRole( int role_id )
{
int i;
RoleInfo *p_info;
wchar_t str[256], tmp_str[256], skillname[32];

p_info = Game_GetRoleInfo( role_id );
Label_TextW( label_role_name, p_info->name );
swprintf( str, sizeof(str), L"%d", p_info->property.max_hp );
Label_TextW( label_hp_value, str );
ProgressBar_SetValue( progbar_punch, p_info->property.punch );
ProgressBar_SetValue( progbar_kick, p_info->property.kick );
ProgressBar_SetValue( progbar_defense, p_info->property.defense );
ProgressBar_SetValue( progbar_throw, p_info->property.throw );
ProgressBar_SetValue( progbar_speed, p_info->property.speed );
GameObject_SwitchAction( role_image, role_id );

wcscpy( str, L"技能列表:\n" );
for(i=0; i<p_info->total_skill; ++i) {
GetSkillName( p_info->skills[i], skillname );
memcpy( tmp_str, str, sizeof(str) );
swprintf( str, sizeof(str), L"%s %s", tmp_str, skillname );
if(i>0 && (i+1)%4 == 0) {
wcscat( str, L"\n" );
}
}
Label_TextW( label_skilllist, str );
}

static void btn_prev_role_clicked( LCUI_Widget *widget, LCUI_WidgetEvent *unused )
Expand Down Expand Up @@ -79,7 +150,31 @@ void Game_InitRoleSelectBox(void)
btn_next_role = Widget_New("button");
btn_select_role = Widget_New("button");

Window_ClientArea_Add( window, role_image_box );
info_area = Widget_New(NULL);
skill_area = Widget_New(NULL);
label_hp_value = Widget_New("label");
label_role_name = Widget_New("label");
label_punch = Widget_New("label");
label_kick = Widget_New("label");
label_defense = Widget_New("label");
label_hp = Widget_New("label");
label_throw = Widget_New("label");
label_speed = Widget_New("label");

progbar_punch = Widget_New("progress_bar");
progbar_kick = Widget_New("progress_bar");
progbar_defense = Widget_New("progress_bar");;
progbar_throw = Widget_New("progress_bar");
progbar_speed = Widget_New("progress_bar");

label_skilllist = Widget_New("label");

Window_ClientArea_Add( window, info_area );
Widget_Resize( info_area, INFO_AREA_SIZE );
Widget_SetAlign( info_area, ALIGN_TOP_CENTER, Pos(0,5) );
Widget_SetBorder( info_area, Border(1,BORDER_STYLE_SOLID, RGB(200,200,200)) );

Widget_Container_Add( info_area, role_image_box );
Widget_Resize( window, WINDOWS_SIZE );
Window_SetTitleTextW( window, L"选择游戏角色" );
Widget_SetAlpha( window, 0 );
Expand All @@ -91,23 +186,23 @@ void Game_InitRoleSelectBox(void)
Widget_SetBorder( role_image_box, Border(1,BORDER_STYLE_SOLID, RGB(200,200,200)) );
Widget_SetBackgroundColor( role_image_box, RGB(230,230,230) );
Widget_SetBackgroundTransparent( role_image_box, FALSE );
Widget_SetAlign( role_image_box, ALIGN_MIDDLE_LEFT, Pos(10,-10) );
Widget_SetAlign( role_image_box, ALIGN_MIDDLE_LEFT, Pos(5,0) );

/* 载入各个角色的START动作 */
for(i=0; i<TOTAL_ROLE_NUM; ++i) {
p_action = ActionRes_Load( i, ACTION_START );
GameObject_AddAction( role_image, p_action, i );
}
current_select_role = ROLE_KUNI;
/* 默认显示ROLE_KUNI角色的动作 */
GameObject_SwitchAction( role_image, ROLE_KUNI );
/* 播放角色的动作动画 */
GameObject_PlayAction( role_image );
/* 将部件加入至角色形象框内 */
GameObject_AddToContainer( role_image, role_image_box );
/* 设置坐标 */
GameObject_SetX( role_image, 45 );
GameObject_SetY( role_image, 100 );
GameObject_SetY( role_image, 90 );
Widget_Container_Add( role_image_box, label_role_name );
Widget_SetAlign( label_role_name, ALIGN_BOTTOM_CENTER, Pos(0,-5) );

/* 设置按钮上显示的文本 */
Button_TextW( btn_next_role, TEXT_NEXT_ROLE );
Expand All @@ -133,13 +228,81 @@ void Game_InitRoleSelectBox(void)
Widget_Event_Connect( btn_prev_role, EVENT_CLICKED, btn_prev_role_clicked );
Widget_Event_Connect( btn_next_role, EVENT_CLICKED, btn_next_role_clicked );
Widget_Event_Connect( btn_select_role, EVENT_CLICKED, btn_select_role_clicked );

Widget_Container_Add( info_area, label_hp );
Widget_Container_Add( info_area, label_hp_value );
Widget_Container_Add( info_area, label_punch );
Widget_Container_Add( info_area, label_kick );
Widget_Container_Add( info_area, label_defense );
Widget_Container_Add( info_area, label_throw );
Widget_Container_Add( info_area, label_speed );
Widget_Container_Add( info_area, progbar_punch );
Widget_Container_Add( info_area, progbar_kick );
Widget_Container_Add( info_area, progbar_defense );
Widget_Container_Add( info_area, progbar_throw );
Widget_Container_Add( info_area, progbar_speed );
/* 设置文本 */
Label_TextW( label_hp, L"生命" );
Label_TextW( label_punch, L"拳力" );
Label_TextW( label_kick, L"腿力" );
Label_TextW( label_defense, L"防御" );
Label_TextW( label_throw, L"投掷" );
Label_TextW( label_speed, L"移速" );
Widget_SetAlign( label_hp, ALIGN_MIDDLE_LEFT, Pos(115,-54) );
Widget_SetAlign( label_punch, ALIGN_MIDDLE_LEFT, Pos(115,-32) );
Widget_SetAlign( label_kick, ALIGN_MIDDLE_LEFT, Pos(115,-10) );
Widget_SetAlign( label_defense, ALIGN_MIDDLE_LEFT, Pos(115,10) );
Widget_SetAlign( label_throw, ALIGN_MIDDLE_LEFT, Pos(115,30) );
Widget_SetAlign( label_speed, ALIGN_MIDDLE_LEFT, Pos(115,52) );
/* 设置进度条 */
ProgressBar_SetMaxValue( progbar_punch, 300 );
ProgressBar_SetMaxValue( progbar_kick, 300 );
ProgressBar_SetMaxValue( progbar_defense, 300 );
ProgressBar_SetMaxValue( progbar_throw, 300 );
ProgressBar_SetMaxValue( progbar_speed, 300 );
Widget_Resize( progbar_punch, Size(145,18) );
Widget_Resize( progbar_kick, Size(145,18) );
Widget_Resize( progbar_defense, Size(145,18) );
Widget_Resize( progbar_throw, Size(145,18) );
Widget_Resize( progbar_speed, Size(145,18) );
Widget_SetAlign( label_hp_value, ALIGN_MIDDLE_LEFT, Pos(145,-54) );
Widget_SetAlign( progbar_punch, ALIGN_MIDDLE_LEFT, Pos(145,-31) );
Widget_SetAlign( progbar_kick, ALIGN_MIDDLE_LEFT, Pos(145,-10) );
Widget_SetAlign( progbar_defense, ALIGN_MIDDLE_LEFT, Pos(145,11) );
Widget_SetAlign( progbar_throw, ALIGN_MIDDLE_LEFT, Pos(145,32) );
Widget_SetAlign( progbar_speed, ALIGN_MIDDLE_LEFT, Pos(145,53) );

Window_ClientArea_Add( window, skill_area );
Widget_Container_Add( skill_area, label_skilllist );
Widget_Resize( skill_area, SKILL_AREA_SIZE );
Widget_SetBorder( skill_area, Border(1,BORDER_STYLE_SOLID, RGB(200,200,200)) );
Widget_SetAlign( skill_area, ALIGN_BOTTOM_CENTER, Pos(0,-50) );
Widget_SetAlign( label_skilllist, ALIGN_TOP_LEFT, Pos(5,5) );

/* 显示这些部件 */
Widget_Show( label_role_name );
Widget_Show( label_hp );
Widget_Show( label_hp_value );
Widget_Show( label_punch );
Widget_Show( label_kick );
Widget_Show( label_defense );
Widget_Show( label_throw );
Widget_Show( label_speed );
Widget_Show( label_skilllist );
Widget_Show( progbar_punch );
Widget_Show( progbar_kick );
Widget_Show( progbar_defense );
Widget_Show( progbar_throw );
Widget_Show( progbar_speed );
Widget_Show( btn_next_role );
Widget_Show( btn_prev_role );
Widget_Show( btn_select_role );
Widget_Show( role_image );
Widget_Show( role_image_box );
Widget_Show( info_area );
Widget_Show( skill_area );

RoleSelectBox_SetRole( ROLE_KUNI );
}

/** 显示角色选择框 */
Expand Down

0 comments on commit 96ada4f

Please sign in to comment.