Skip to content

Commit 5d6f273

Browse files
committed
Add color() method to extensions
Resolves: #582
1 parent b3117dc commit 5d6f273

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+167
-3
lines changed

include/scratchcpp/iextension.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
#pragma once
44

5-
#include <string>
6-
7-
#include "global.h"
5+
#include "value_functions.h"
86

97
namespace libscratchcpp
108
{
@@ -27,6 +25,9 @@ class LIBSCRATCHCPP_EXPORT IExtension
2725
/*! Returns the description of the extension. */
2826
virtual std::string description() const = 0;
2927

28+
/*! Returns the block color of the extension. */
29+
virtual Rgb color() const = 0;
30+
3031
/*! Override this method to register blocks. */
3132
virtual void registerBlocks(IEngine *engine) = 0;
3233

src/blocks/controlblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ std::string ControlBlocks::description() const
2525
return name() + " blocks";
2626
}
2727

28+
Rgb ControlBlocks::color() const
29+
{
30+
return rgb(255, 171, 25);
31+
}
32+
2833
void ControlBlocks::registerBlocks(IEngine *engine)
2934
{
3035
// Blocks

src/blocks/controlblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ControlBlocks : public IExtension
4343

4444
std::string name() const override;
4545
std::string description() const override;
46+
Rgb color() const override;
4647

4748
void registerBlocks(IEngine *engine) override;
4849

src/blocks/customblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ std::string CustomBlocks::description() const
2020
return name();
2121
}
2222

23+
Rgb CustomBlocks::color() const
24+
{
25+
return rgb(255, 102, 128);
26+
}
27+
2328
void CustomBlocks::registerBlocks(IEngine *engine)
2429
{
2530
// Blocks

src/blocks/customblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CustomBlocks : public IExtension
2424

2525
std::string name() const override;
2626
std::string description() const override;
27+
Rgb color() const override;
2728

2829
void registerBlocks(IEngine *engine) override;
2930

src/blocks/eventblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ std::string libscratchcpp::EventBlocks::description() const
3030
return "Event blocks";
3131
}
3232

33+
Rgb EventBlocks::color() const
34+
{
35+
return rgb(255, 191, 0);
36+
}
37+
3338
void EventBlocks::registerBlocks(IEngine *engine)
3439
{
3540
// Blocks

src/blocks/eventblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class EventBlocks : public IExtension
3838

3939
std::string name() const override;
4040
std::string description() const override;
41+
Rgb color() const override;
4142

4243
void registerBlocks(IEngine *engine) override;
4344

src/blocks/listblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ std::string ListBlocks::description() const
2323
return "List blocks";
2424
}
2525

26+
Rgb ListBlocks::color() const
27+
{
28+
return rgb(255, 102, 26);
29+
}
30+
2631
void ListBlocks::registerBlocks(IEngine *engine)
2732
{
2833
// Blocks

src/blocks/listblocks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ListBlocks : public IExtension
2828

2929
std::string name() const override;
3030
std::string description() const override;
31+
Rgb color() const override;
3132

3233
void registerBlocks(IEngine *engine) override;
3334

src/blocks/looksblocks.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ std::string LooksBlocks::description() const
4242
return name() + " blocks";
4343
}
4444

45+
Rgb LooksBlocks::color() const
46+
{
47+
return rgb(153, 102, 255);
48+
}
49+
4550
void LooksBlocks::registerBlocks(IEngine *engine)
4651
{
4752
// Blocks

0 commit comments

Comments
 (0)