Skip to content

Commit

Permalink
Moved MI_PacksField to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Dec 3, 2023
1 parent 70742cf commit f583b32
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 58 deletions.
2 changes: 2 additions & 0 deletions src/smw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ target_sources(smw PRIVATE
ui/MI_WorldPreviewDisplay.h
ui/MI_AnnouncerField.cpp
ui/MI_AnnouncerField.h
ui/MI_PacksField.cpp
ui/MI_PacksField.h
)

if(NO_NETWORK)
Expand Down
3 changes: 3 additions & 0 deletions src/smw/menu/options/GraphicsOptionsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
#include "FileList.h"
#include "GameValues.h"
#include "ResourceManager.h"
#include "ui/MI_Button.h"
#include "ui/MI_Image.h"
#include "ui/MI_PacksField.h"
#include "ui/MI_SelectField.h"
#include "ui/MI_Text.h"

extern CResourceManager* rm;
Expand Down
9 changes: 7 additions & 2 deletions src/smw/menu/options/GraphicsOptionsMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
#define MENU_GRAPHICSOPTIONS_H

#include "uimenu.h"
#include "uicontrol.h"
#include "uicustomcontrol.h"

class MI_Button;
class MI_Image;
class MI_PacksField;
class MI_SelectField;
class MI_Text;


/*
You can switch between windowed and fullscreen mode,
Expand Down
5 changes: 3 additions & 2 deletions src/smw/menu/options/SoundOptionsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
#include "FileList.h"
#include "GameValues.h"
#include "ResourceManager.h"
#include "ui/MI_Image.h"
#include "ui/MI_Text.h"
#include "ui/MI_AnnouncerField.h"
#include "ui/MI_Button.h"
#include "ui/MI_Image.h"
#include "ui/MI_PacksField.h"
#include "ui/MI_SelectField.h"
#include "ui/MI_SliderField.h"
#include "ui/MI_Text.h"
#include "uicustomcontrol.h"

extern CResourceManager* rm;
Expand Down
1 change: 0 additions & 1 deletion src/smw/ui/MI_AnnouncerField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "gfx.h"
#include "input.h"
#include "ResourceManager.h"
#include "ui/MI_Image.h"

extern CResourceManager* rm;

Expand Down
2 changes: 1 addition & 1 deletion src/smw/ui/MI_AnnouncerField.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once

#include "uicontrol.h"
#include "ui/MI_Image.h"

#include <memory>
#include <string>

class gfxSprite;
class MI_Image;
class SimpleFileList;


Expand Down
37 changes: 37 additions & 0 deletions src/smw/ui/MI_PacksField.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "MI_PacksField.h"

#include "FileList.h"
#include "input.h"


MI_PacksField::MI_PacksField(gfxSprite* nspr, short x, short y, std::string name, short width, short indent, SimpleFileList* pList, MenuCodeEnum code)
: MI_AnnouncerField(nspr, x, y, std::move(name), width, indent, pList)
, itemChangedCode(code)
{}


MenuCodeEnum MI_PacksField::SendInput(CPlayerInput* playerInput)
{
int iLastIndex = list->GetCurrentIndex();
MenuCodeEnum code = MI_AnnouncerField::SendInput(playerInput);

if (MENU_CODE_UNSELECT_ITEM == code)
return code;

MenuCodeEnum returnCode = MENU_CODE_NONE;
if (iLastIndex != list->GetCurrentIndex())
returnCode = itemChangedCode;

for (int iPlayer = 0; iPlayer < 4; iPlayer++) {
if (playerInput->outputControls[iPlayer].menu_right.fPressed || playerInput->outputControls[iPlayer].menu_down.fPressed)
return returnCode;

if (playerInput->outputControls[iPlayer].menu_left.fPressed || playerInput->outputControls[iPlayer].menu_up.fPressed)
return returnCode;

if (playerInput->outputControls[iPlayer].menu_random.fPressed)
return returnCode;
}

return MENU_CODE_NONE;
}
14 changes: 14 additions & 0 deletions src/smw/ui/MI_PacksField.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

#include "MI_AnnouncerField.h"


class MI_PacksField : public MI_AnnouncerField {
public:
MI_PacksField(gfxSprite* nspr, short x, short y, std::string name, short width, short indent, SimpleFileList* pList, MenuCodeEnum code);

MenuCodeEnum SendInput(CPlayerInput * playerInput) override;

private:
const MenuCodeEnum itemChangedCode = MENU_CODE_NONE;
};
39 changes: 0 additions & 39 deletions src/smw/uicustomcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,45 +54,6 @@ extern CResourceManager* rm;
extern CGame* smw;


/**************************************
* MI_PacksField Class
**************************************/

MI_PacksField::MI_PacksField(gfxSprite * nspr, short x, short y, const char * name, short width, short indent, SimpleFileList * pList, MenuCodeEnum code) :
MI_AnnouncerField(nspr, x, y, name, width, indent, pList)
{
itemChangedCode = code;
}

MI_PacksField::~MI_PacksField()
{}

MenuCodeEnum MI_PacksField::SendInput(CPlayerInput * playerInput)
{
int iLastIndex = list->GetCurrentIndex();
MenuCodeEnum code = MI_AnnouncerField::SendInput(playerInput);

if (MENU_CODE_UNSELECT_ITEM == code)
return code;

MenuCodeEnum returnCode = MENU_CODE_NONE;
if (iLastIndex != list->GetCurrentIndex())
returnCode = itemChangedCode;

for (int iPlayer = 0; iPlayer < 4; iPlayer++) {
if (playerInput->outputControls[iPlayer].menu_right.fPressed || playerInput->outputControls[iPlayer].menu_down.fPressed)
return returnCode;

if (playerInput->outputControls[iPlayer].menu_left.fPressed || playerInput->outputControls[iPlayer].menu_up.fPressed)
return returnCode;

if (playerInput->outputControls[iPlayer].menu_random.fPressed)
return returnCode;
}

return MENU_CODE_NONE;
}

/**************************************
* MI_PlayListField Class
**************************************/
Expand Down
13 changes: 0 additions & 13 deletions src/smw/uicustomcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ class MI_ScoreText;
class MI_Text;


class MI_PacksField : public MI_AnnouncerField
{
public:

MI_PacksField(gfxSprite * nspr, short x, short y, const char * name, short width, short indent, SimpleFileList * pList, MenuCodeEnum code);
virtual ~MI_PacksField();

MenuCodeEnum SendInput(CPlayerInput * playerInput);

private:
MenuCodeEnum itemChangedCode;
};

class MI_PlaylistField : public UI_Control
{
public:
Expand Down

0 comments on commit f583b32

Please sign in to comment.