📄 matlab-russian.txt
字号:
% 修改名称
ScoreInfo(ScoreIndex).Name = PlayerName ;
% 保存
setappdata( handles.RussiaBlock, 'ScoreInfo', ScoreInfo) ;
% -------------------------------------------------------------------------
function GameLevel_Callback( h )
handles = guidata( h ) ;
% 设置游戏难度
ScoreFigure = figure( 'name', '游戏难度设置', 'menubar', 'none', 'numbertitle', 'off',...
'pos', [200 200 200 180], 'windowstyle', 'modal', 'resize', 'off' ) ;
% 列表框
uicontrol( 'Parent', ScoreFigure, 'Style', 'listbox', 'Pos', [20 20 80 140],...
'String', [sprintf( '%d 级|', 1:8 ),'9 级'] ) ;
% 确定按钮
uicontrol( 'Parent', ScoreFigure, 'Style', 'pushbutton', 'Pos', [120 100 60 50], 'String', '确定',...
'Cal', ['GameLevel = get( findobj( ''Style'', ''listbox''), ''Value'');',...
'set( 0, ''Userdata'', GameLevel ); close( gcf );'] ) ;
% 取消按钮
uicontrol( 'Parent', ScoreFigure, 'Style', 'pushbutton', 'Pos', [120 30 60 50], 'String', '取消',...
'Cal', 'close( gcf )' ) ;
% 界面关系后才响应
waitfor( ScoreFigure ) ;
ButtonAction = questdlg( '重新设置游戏难度将初始化界面,是否继续?', '设置确认', '是的', '取消', '取消' ) ;
if strcmp( '取消', ButtonAction )
return
end
GameLevel = get( 0, 'Userdata' ) ;
% 更新游戏难度
setappdata( handles.RussiaBlock, 'GameLevel', GameLevel ) ;
setappdata( handles.RussiaBlock, 'UseSetGameLevel', GameLevel ) ;
% 更新暂停时间
global PauseTime
PauseTime = GetPauseTimeByGameLevel( GameLevel ) ;
% -------------------------------------------------------------------------
function HighScore_Callback( h )
% 查看最高记录
handles = guidata( h ) ;
ScoreInfo = getappdata( handles.RussiaBlock, 'ScoreInfo' ) ;
% 最高记录界面
ScoreFigure = figure( 'name', '最高记录', 'menubar', 'none', 'numbertitle', 'off',...
'pos', [200 200 400 140], 'windowstyle', 'modal', 'resize', 'off' ) ;
AxesHandle = axes( 'parent', ScoreFigure, 'pos', [0 0 1 1], 'xlim', [0 100], 'ylim', [0 100],...
'xtick', [], 'ytick', [], 'visible', 'on', 'color', [1 1 1]) ;
% 第一名
text( 16, 80, '第一名', 'parent', AxesHandle, 'color', [1 0 0], 'fontsize', 13, 'horizontalalignment', 'right' ) ;
text( 45, 80, ScoreInfo(1).Name, 'parent', AxesHandle, 'color', [1 0 0], 'fontsize', 13, 'horizontalalignment', 'center' ) ;
text( 85, 80, num2str(ScoreInfo(1).Score), 'parent', AxesHandle, 'color', [1 0 0], 'fontsize', 13, 'horizontalalignment', 'center' ) ;
% 第二名
text( 16, 50, '第二名', 'parent', AxesHandle, 'color', [0 1 0.7], 'fontsize', 13, 'horizontalalignment', 'right') ;
text( 45, 50, ScoreInfo(2).Name, 'parent', AxesHandle, 'color', [0 1 0.7], 'fontsize', 13, 'horizontalalignment', 'center') ;
text( 85, 50, num2str(ScoreInfo(2).Score), 'parent', AxesHandle, 'color', [0 1 0.7], 'fontsize', 13, 'horizontalalignment', 'center' ) ;
% 第三名
text( 16, 20, '第三名', 'parent', AxesHandle, 'color', [0 0 1], 'fontsize', 13, 'horizontalalignment', 'right' ) ;
text( 45, 20, ScoreInfo(3).Name, 'parent', AxesHandle, 'color', [0 0 1], 'fontsize', 13, 'horizontalalignment', 'center' ) ;
text( 85, 20, num2str(ScoreInfo(3).Score), 'parent', AxesHandle, 'color', [0 0 1], 'fontsize', 13, 'horizontalalignment', 'center' ) ;
% 画两条线
line([0 100 nan 0 100], [65 65 nan 35 35]) ;
% -------------------------------------------------------------------------
function SaveGame_Callback( h )
% 保存游戏
handles = guidata( h ) ;
% 存储的信息
SaveGameInfo = [] ;
try
% 载入
SaveGameInfo = load('SaveGameInfo.mat') ;
catch
end
% 载入失败,重新生成
if isempty( SaveGameInfo )
SaveGameInfo = [] ;
else
SaveGameInfo = SaveGameInfo.SaveGameInfo ;
end
% 设置保存游戏
ScoreFigure = figure( 'name', '游戏进度保存', 'menubar', 'none', 'numbertitle', 'off',...
'pos', [200 200 400 180], 'windowstyle', 'modal', 'resize', 'off' ) ;
if isempty(SaveGameInfo)
SaveList = sprintf( '进度%d (空的) |', 1:9 ) ;
else
SaveList = {SaveGameInfo.Name};
end
setappdata( ScoreFigure, 'RussiaBlockFigureHandle', handles.RussiaBlock ) ;
% 列表框
uicontrol( 'Parent', ScoreFigure, 'Style', 'listbox', 'Pos', [20 20 280 140],...
'String', SaveList ) ;
% 确定按钮
uicontrol( 'Parent', ScoreFigure, 'Style', 'pushbutton', 'Pos', [320 100 60 50], 'String', '确定',...
'Cal', ['FigureHandle = getappdata(gcf, ''RussiaBlockFigureHandle'');',...
'SaveIndex = get( findobj( ''Style'', ''listbox''), ''Value'');RussiaBlock(''SaveGame'', FigureHandle, SaveIndex);close( gcf );'] ) ;
% 取消按钮
uicontrol( 'Parent', ScoreFigure, 'Style', 'pushbutton', 'Pos', [320 30 60 50], 'String', '取消',...
'Cal', 'close( gcf )' ) ;
% 界面关系后才响应
waitfor( ScoreFigure ) ;
% -------------------------------------------------------------------------
function LoadGame_Callback( h )
% 保存游戏
handles = guidata( h ) ;
% 存储的信息
SaveGameInfo = [] ;
try
% 载入
SaveGameInfo = load('SaveGameInfo.mat') ;
catch
end
% 载入失败,重新生成
if isempty( SaveGameInfo )
SaveGameInfo = [] ;
else
SaveGameInfo = SaveGameInfo.SaveGameInfo ;
end
% 设置保存游戏
ScoreFigure = figure( 'name', '游戏进度读取', 'menubar', 'none', 'numbertitle', 'off',...
'pos', [200 200 400 180], 'windowstyle', 'modal', 'resize', 'off' ) ;
if isempty(SaveGameInfo)
SaveList = sprintf( '进度%d (空的) |', 1:9 ) ;
else
SaveList = {SaveGameInfo.Name};
end
setappdata( ScoreFigure, 'RussiaBlockFigureHandle', handles.RussiaBlock ) ;
% 列表框
uicontrol( 'Parent', ScoreFigure, 'Style', 'listbox', 'Pos', [20 20 280 140],...
'String', SaveList ) ;
% 确定按钮
uicontrol( 'Parent', ScoreFigure, 'Style', 'pushbutton', 'Pos', [320 100 60 50], 'String', '确定',...
'Cal', ['FigureHandle = getappdata(gcf, ''RussiaBlockFigureHandle'');',...
'SaveIndex = get( findobj( ''Style'', ''listbox''), ''Value'');',...
'if RussiaBlock(''LoadGame'', FigureHandle, SaveIndex);close( gcf ); RussiaBlock( ''StartNewGame_Callback'', FigureHandle, ''Continue'' ) ;else;end'] ) ;
% 取消按钮
uicontrol( 'Parent', ScoreFigure, 'Style', 'pushbutton', 'Pos', [320 30 60 50], 'String', '取消',...
'Cal', 'close( gcf )' ) ;
% 界面关系后才响应
waitfor( ScoreFigure ) ;
% -------------------------------------------------------------------------
function SaveGame( h, SaveIndex )
handles = guidata( h ) ;
% 存储的信息
SaveGameInfo = [] ;
try
% 载入
SaveGameInfo = load('SaveGameInfo.mat') ;
catch
end
if isempty(SaveGameInfo)
for num = 1: 9
SaveGameInfo(num).Name = ['进度', num2str(num), ' (空的)'] ;
SaveGameInfo(num).Data = [] ;
end
else
SaveGameInfo = SaveGameInfo.SaveGameInfo;
end
% 进度的名称
SaveGameInfo(SaveIndex).Name = ['进度', num2str(SaveIndex), ' (积分:', num2str(getappdata( handles.RussiaBlock, 'CurrentScore' )),...
'; 保存于:', datestr(clock), ')'] ;
% 需要保存的
SaveGameInfo(SaveIndex).Data.BlockHandle.XData = get( handles.BlockHandle, 'XData') ;
SaveGameInfo(SaveIndex).Data.BlockHandle.YData = get( handles.BlockHandle, 'YData') ;
SaveGameInfo(SaveIndex).Data.TempBlock.XData = get( handles.TempBlock, 'XData') ;
SaveGameInfo(SaveIndex).Data.TempBlock.YData = get( handles.TempBlock, 'YData') ;
SaveGameInfo(SaveIndex).Data.NextBlock.XData = get( handles.NextBlock, 'XData') ;
SaveGameInfo(SaveIndex).Data.NextBlock.YData = get( handles.NextBlock, 'YData') ;
SaveGameInfo(SaveIndex).Data.BlockArray = getappdata( handles.RussiaBlock, 'BlockArray' ) ;
SaveGameInfo(SaveIndex).Data.Score = getappdata( handles.RussiaBlock, 'CurrentScore' ) ;
SaveGameInfo(SaveIndex).Data.UseSetGameLevel = getappdata( handles.RussiaBlock, 'UseSetGameLevel' ) ;
SaveGameInfo(SaveIndex).Data.TempBlockPos = getappdata( handles.RussiaBlock, 'TempBlockPos' ) ;
SaveGameInfo(SaveIndex).Data.BlockNumber = getappdata( handles.RussiaBlock, 'BlockNumber' ) ;
save SaveGameInfo.mat SaveGameInfo
% -------------------------------------------------------------------------
function status = LoadGame( h, SaveIndex )
status = 0 ;
handles = guidata( h ) ;
% 存储的信息
SaveGameInfo = [] ;
try
% 载入
SaveGameInfo = load('SaveGameInfo.mat') ;
catch
end
if isempty(SaveGameInfo)
warndlg('这个进度是空的', '警告');
return;
else
SaveGameInfo = SaveGameInfo.SaveGameInfo;
end
if isempty(SaveGameInfo(SaveIndex).Data)
warndlg('这个进度是空的', '警告');
return;
end
set( handles.BlockHandle, 'XData',SaveGameInfo(SaveIndex).Data.BlockHandle.XData) ;
set( handles.BlockHandle, 'YData',SaveGameInfo(SaveIndex).Data.BlockHandle.YData) ;
set( handles.TempBlock, 'XData',SaveGameInfo(SaveIndex).Data.TempBlock.XData) ;
set( handles.TempBlock, 'YData',SaveGameInfo(SaveIndex).Data.TempBlock.YData) ;
set( handles.NextBlock, 'XData',SaveGameInfo(SaveIndex).Data.NextBlock.XData) ;
set( handles.NextBlock, 'YData',SaveGameInfo(SaveIndex).Data.NextBlock.YData) ;
setappdata( handles.RussiaBlock, 'BlockArray', SaveGameInfo(SaveIndex).Data.BlockArray ) ;
setappdata( handles.RussiaBlock, 'CurrentScore', SaveGameInfo(SaveIndex).Data.Score ) ;
setappdata( handles.RussiaBlock, 'UseSetGameLevel', SaveGameInfo(SaveIndex).Data.UseSetGameLevel ) ;
setappdata( handles.RussiaBlock, 'TempBlockPos', SaveGameInfo(SaveIndex).Data.TempBlockPos ) ;
setappdata( handles.RussiaBlock, 'BlockNumber', SaveGameInfo(SaveIndex).Data.BlockNumber ) ;
% 更新游戏速度
setappdata( handles.RussiaBlock, 'GameLevel', 1 ) ;
UpdateGameLevel( handles.RussiaBlock, SaveGameInfo(SaveIndex).Data.Score ) ;
% 更新显示
set( handles.BlockNumText, 'String', {'方块数', num2str(SaveGameInfo(SaveIndex).Data.BlockNumber)} ) ;
set( handles.ScoreText, 'String', {'积分', num2str(SaveGameInfo(SaveIndex).Data.Score)}) ;
status = 1 ;
% -------------------------------------------------------------------------
function BoardConfig_Callback( h )
MainHandles = guidata( h ) ;
% 键盘设置
ScoreFigure = figure( 'name', '键盘设置', 'menubar', 'none', 'numbertitle', 'off',...
'tag', 'ScoreFigure', 'pos', [200 200 200 250], 'windowstyle', 'modal', 'resize', 'off',...
'keypressfcn', 'RussiaBlock(''BoardConfigFigureKeyPress'', gcbo )' ) ;
% 文本框
uicontrol('style', 'text', 'position', [30 200 60 22], 'string', '向左') ;
uicontrol('style', 'text', 'position', [30 170 60 22], 'string', '向右') ;
uicontrol('style', 'text', 'position', [30 140 60 22], 'string', '向下') ;
uicontrol('style', 'text', 'position', [30 110 60 22], 'string', '变形') ;
uicontrol('style', 'text', 'position', [30 80 60 22], 'string', '丢下') ;
% 编辑框
edit(1) = uicontrol( 'style', 'edit', 'position', [110 200 70 22],...
'enable', 'inactive', 'tag', 'left', 'backgroundcolor', [0.7 0.7 0.7],...
'buttondownfcn', 'RussiaBlock(''UpdateBoardConfigEditColor'', gcbo )') ;
edit(2) = uicontrol( 'style', 'edit', 'position', [110 170 70 22],...
'enable', 'inactive', 'tag', 'right', 'backgroundcolor', [0.7 0.7 0.7],...
'buttondownfcn', 'RussiaBlock(''UpdateBoardConfigEditColor'', gcbo )') ;
edit(3) = uicontrol( 'style', 'edit', 'position', [110 140 70 22],...
'enable', 'inactive', 'tag', 'down', 'backgroundcolor', [0.7 0.7 0.7],...
'buttondownfcn', 'RussiaBlock(''UpdateBoardConfigEditColor'', gcbo )') ;
edit(4) = uicontrol( 'style', 'edit', 'position', [110 110 70 22],...
'enable', 'inactive', 'tag', 'change', 'backgroundcolor', [0.7 0.7 0.7],...
'buttondownfcn', 'RussiaBlock(''UpdateBoardConfigEditColor'', gcbo )') ;
edit(5) = uicontrol( 'style', 'edit', 'position', [110 80 70 22],...
'enable', 'inactive', 'tag', 'drop', 'backgroundcolor', [0.7 0.7 0.7],...
'buttondownfcn', 'RussiaBlock(''UpdateBoardConfigEditColor'', gcbo )') ;
setappdata( ScoreFigure, 'EditHandles', edit ) ;
uicontrol('style', 'pushbutton', 'position', [25 30 70 25],...
'string', '确定', 'cal', 'RussiaBlock(''SaveBoardConfig'', gcbo );close(gcf)') ;
uicontrol('style', 'pushbutton', 'position', [110 30 70 25],...
'string', '取消', 'cal', 'close(gcf)') ;
handles = guihandles( ScoreFigure ) ;
handles.RussiaBlock = MainHandles.RussiaBlock;
guidata(ScoreFigure, handles) ;
initBoardConfig( ScoreFigure ) ;
waitfor(ScoreFigure) ;
% -------------------------------------------------------------------------
function initBoardConfig( ScoreFigure )
handles = guidata( ScoreFigure ) ;
% 用户设置的前后左右和直接下落键
BoardConfig = getappdata( handles.RussiaBlock, 'BoardConfig' ) ;
set( handles.left, 'string', BoardConfig.Left ) ;
set( handles.right, 'string', BoardConfig.Right ) ;
set( handles.down, 'string', BoardConfig.Down ) ;
set( handles.change, 'string', BoardConfig.Change ) ;
set( handles.drop, 'string', BoardConfig.Drop ) ;
% -------------------------------------------------------------------------
function BoardConfigFigureKeyPress( h )
handles = guidata( h ) ;
TempBoardConfigEditHandle = getappdata( handles.RussiaBlock, 'TempBoardConfigEditHandle' ) ;
key = get( handles.ScoreFigure, 'currentkey' ) ;
set( TempBoardConfigEditHandle, 'string', key ) ;
% -------------------------------------------------------------------------
function UpdateBoardConfigEditColor( h )
handles = guidata( h ) ;
EditHandles = getappdata( handles.ScoreFigure, 'EditHandles' ) ;
set( EditHandles, 'backgroundcolor', [0.7 0.7 0.7] ) ;
TempEditTag = get( h, 'tag' ) ;
TempBoardConfigEditHandle = getfield( handles, TempEditTag ) ;
set( TempBoardConfigEditHandle, 'backgroundcolor', [0 0.9 0.9] ) ;
setappdata( handles.RussiaBlock, 'TempBoardConfigEditHandle', TempBoardConfigEditHandle ) ;
% -------------------------------------------------------------------------
function SaveBoardConfig( h )
handles = guidata( h ) ;
BoardConfig.Left = get( handles.left, 'string') ;
BoardConfig.Right = get( handles.right, 'string') ;
BoardConfig.Down = get( handles.down, 'string') ;
BoardConfig.Change = get( handles.change, 'string') ;
BoardConfig.Drop = get( handles.drop, 'string') ;
% 用户设置的前后左右和直接下落键
setappdata( handles.RussiaBlock, 'BoardConfig', BoardConfig ) ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -