begun work on os specific scripts

master
tasgoon 2016-02-09 23:02:52 -05:00
parent de4d1d2ef3
commit 520cd6802c
8 changed files with 101 additions and 10 deletions

View File

@ -26,3 +26,6 @@ HEADERS += mainwindow.h \
FORMS += mainwindow.ui \
createdialog.ui
RESOURCES += \
scripts.qrc

View File

@ -7,6 +7,7 @@ MainWindow::MainWindow(QWidget *parent) :
{
ui->setupUi(this);
connect(ui->createBtn, SIGNAL(clicked()), this, SLOT(newProfile()));
connect(ui->deleteBtn, SIGNAL(clicked()), this, SLOT(deleteSelected()));
}
MainWindow::~MainWindow()
@ -18,5 +19,10 @@ void MainWindow::newProfile()
{
CreateDialog::newProfile(manager);
manager->refreshList(ui->comboBox);
qDebug() << "Manager size:" << manager->profiles.size();
}
void MainWindow::deleteSelected()
{
manager->deleteByName(ui->comboBox->currentText());
manager->refreshList(ui->comboBox);
}

View File

@ -16,8 +16,9 @@ public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public slots:
private slots:
void newProfile();
void deleteSelected();
private:
Ui::MainWindow *ui;

View File

@ -47,13 +47,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="editBtn">
<property name="text">
<string>Edit</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteBtn">
<property name="text">
@ -101,7 +94,7 @@
<x>0</x>
<y>0</y>
<width>1099</width>
<height>30</height>
<height>19</height>
</rect>
</property>
</widget>

View File

@ -7,7 +7,23 @@ ProfileManager::ProfileManager()
bool ProfileManager::addProfile(Profile profile)
{
for (Profile p : profiles)
if (p.getName() == profile.getName())
return false;
profiles.push_back(profile);
return true;
}
bool ProfileManager::deleteByName(QString name)
{
for (int i = 0; i < profiles.size(); i++)
if (profiles[i].getName() == name)
{
profiles.erase(profiles.begin() + i);
return true;
}
return false;
}
void ProfileManager::refreshList(QComboBox *box)

View File

@ -12,6 +12,7 @@ class ProfileManager
public:
ProfileManager();
bool addProfile(Profile);
bool deleteByName(QString);
void refreshList(QComboBox*);
vector<Profile> profiles;
};

1
scripts.qrc Normal file
View File

@ -0,0 +1 @@
<RCC/>

70
scripts/linux.sh Executable file
View File

@ -0,0 +1,70 @@
#!/bin/bash
# Linux instance creator
# $1 - Action to take
# $2 - Instance name
# $3 - Version to create the instance with
TARGET=~/.minetest/instances/$2
libs () {
if ! ls -R /usr/include |grep irrlicht
then
if [ $(which pacman) -neq "pacman not found" ]
then
sudo pacman -S irrlicht
elif [ $(which apt-get) -neq "apt-get not found" ]
then
sudo apt-get install libirrlicht-dev
else
echo "Cannot automatically install irrlicht libraries. Please do so yourself before installing irrlicht"
fi
fi
}
# Minetest installer function
install () {
MINETEST_LINK=https://codeload.github.com/minetest/minetest/tar.gz/$VERSION
GAME_LINK=https://codeload.github.com/minetest/minetest_game/tar.gz/$VERSION
echo "Creating instance directory"
mkdir -p $TARGET
cd $TARGET
echo "Downloading instance from $MINETEST_LINK"
curl -o src.tar.gz $MINETEST_LINK
tar -xvf src.tar.gz
rm src.tar.gz
mv minetest-$VERSION/* .
rm -r minetest-$VERSION
echo "Compiling Minetest"
cmake . && make -j$(($(cat /proc/cpuinfo |grep processor |wc -l) * 2))
echo "Downloading Minetest game from $GAME_LINK"
cd games
curl -o game.tar.gz $GAME_LINK
tar -xvf game.tar.gz
mv minetest_game* minetest_game
rm game.tar.gz
}
case $1 in
help)
echo "list - list all current installed instances"
echo "create - create a new Minetest instance"
echo "play - play an instance"
;;
list)
ls -1 ~/.minetest/instances
;;
create)
VERSION=$3
libs
install
;;
play)
cd $TARGET
./bin/minetest
esac